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>
19 #define berValidate blobValidate
25 /* any value allowed */
36 unsigned char *u = in->bv_val;
38 for( count = in->bv_len; count > 0; count-=len, u+=len ) {
39 /* get the length indicated by the first byte */
40 len = LDAP_UTF8_CHARLEN( u );
42 /* should not be zero */
43 if( len == 0 ) return -1;
45 /* make sure len corresponds with the offset
46 to the next character */
47 if( LDAP_UTF8_OFFSET( u ) != len ) return -1;
50 if( count != 0 ) return -1;
61 struct berval **normalized )
63 struct berval *newval;
66 newval = ch_malloc( sizeof( struct berval ) );
70 /* Ignore initial whitespace */
71 while ( ldap_utf8_isspace( p ) ) {
80 newval->bv_val = ch_strdup( p );
81 p = q = newval->bv_val;
87 if ( ldap_utf8_isspace( p ) ) {
88 len = LDAP_UTF8_COPY(q,p);
93 /* Ignore the extra whitespace */
94 while ( ldap_utf8_isspace( p ) ) {
98 len = LDAP_UTF8_COPY(q,p);
105 assert( *newval->bv_val );
106 assert( newval->bv_val < p );
109 /* cannot start with a space */
110 assert( !ldap_utf8_isspace(newval->bv_val) );
113 * If the string ended in space, backup the pointer one
114 * position. One is enough because the above loop collapsed
115 * all whitespace to a single space.
122 /* cannot end with a space */
123 assert( !ldap_utf8_isspace( LDAP_UTF8_PREV(q) ) );
128 newval->bv_len = q - newval->bv_val;
129 normalized = &newval;
141 if( val->bv_len == 0 ) return 0;
143 if( isdigit(val->bv_val[0]) ) {
145 for(i=1; i < val->bv_len; i++) {
146 if( val->bv_val[i] == '.' ) {
147 if( dot++ ) return 1;
148 } else if ( isdigit(val->bv_val[i]) ) {
157 } else if( isalpha(val->bv_val[0]) ) {
158 for(i=1; i < val->bv_len; i++) {
159 if( !isalpha(val->bv_val[i] ) ) {
177 for(i=0; i < val->bv_len; i++) {
178 if( !isdigit(val->bv_val[i]) ) return -1;
185 printableStringValidate(
191 for(i=0; i < val->bv_len; i++) {
192 if( !isprint(val->bv_val[i]) ) return -1;
205 for(i=0; i < val->bv_len; i++) {
206 if( !isascii(val->bv_val[i]) ) return -1;
216 struct berval **out )
219 ber_len_t i, len = in->bv_len;
220 struct berval *bv = ch_malloc( sizeof(struct berval) );
222 bv->bv_len = len * sizeof( ldap_unicode_t );
223 bv->bv_val = (char *) u = ch_malloc( bv->bv_len + sizeof( ldap_unicode_t ) );;
225 for(i=0; i < len; i++ ) {
227 * IA5StringValidate should have been called to ensure
228 * input is limited to IA5.
230 u[i] = in->bv_val[i];
244 struct berval **normalized )
246 struct berval *newval;
249 newval = ch_malloc( sizeof( struct berval ) );
253 /* Ignore initial whitespace */
254 while ( isspace( *p++ ) ) {
263 newval->bv_val = ch_strdup( p );
264 p = q = newval->bv_val;
267 if ( isspace( *p ) ) {
270 /* Ignore the extra whitespace */
271 while ( isspace( *p++ ) ) {
279 assert( *newval->bv_val );
280 assert( newval->bv_val < p );
283 /* cannot start with a space */
284 assert( !isspace(*newval->bv_val) );
287 * If the string ended in space, backup the pointer one
288 * position. One is enough because the above loop collapsed
289 * all whitespace to a single space.
292 if ( isspace( q[-1] ) ) {
296 /* cannot end with a space */
297 assert( !isspace( q[-1] ) );
302 newval->bv_len = q - newval->bv_val;
303 normalized = &newval;
313 struct berval *value,
314 void *assertedValue )
316 return strcmp( value->bv_val,
317 ((struct berval *) assertedValue)->bv_val );
325 struct berval *value,
326 void *assertedValue )
328 return strcasecmp( value->bv_val,
329 ((struct berval *) assertedValue)->bv_val );
332 struct syntax_defs_rec {
335 slap_syntax_validate_func *sd_validate;
336 slap_syntax_transform_func *sd_ber2str;
337 slap_syntax_transform_func *sd_str2ber;
340 #define X_BINARY "X-BINARY-TRANSFER-REQUIRED 'TRUE' "
341 #define X_NOT_H_R "X-NOT-HUMAN-READABLE 'TRUE' "
343 struct syntax_defs_rec syntax_defs[] = {
344 {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' " X_BINARY X_NOT_H_R ")",
345 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
346 {"( 1.3.6.1.4.1.1466.115.121.1.2 DESC 'Access Point' " X_NOT_H_R ")",
347 0, NULL, NULL, NULL},
348 {"( 1.3.6.1.4.1.1466.115.121.1.3 DESC 'Attribute Type Description' )",
349 0, NULL, NULL, NULL},
350 {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' " X_NOT_H_R ")",
351 SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
352 {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' " X_BINARY X_NOT_H_R ")",
353 SLAP_SYNTAX_BER, berValidate, NULL, NULL},
354 {"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
355 0, NULL, NULL, NULL},
356 {"( 1.3.6.1.4.1.1466.115.121.1.7 DESC 'Boolean' )",
357 0, NULL, NULL, NULL},
358 {"( 1.3.6.1.4.1.1466.115.121.1.8 DESC 'Certificate' "
359 X_BINARY X_NOT_H_R ")",
360 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
361 {"( 1.3.6.1.4.1.1466.115.121.1.9 DESC 'Certificate List' "
362 X_BINARY X_NOT_H_R ")",
363 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
364 {"( 1.3.6.1.4.1.1466.115.121.1.10 DESC 'Certificate Pair' "
365 X_BINARY X_NOT_H_R ")",
366 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
367 {"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )",
368 0, NULL, NULL, NULL},
369 {"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'DN' )",
370 0, blobValidate, NULL, NULL},
371 {"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )",
372 0, NULL, NULL, NULL},
373 {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
374 0, NULL, NULL, NULL},
375 {"( 1.3.6.1.4.1.1466.115.121.1.15 DESC 'Directory String' )",
376 0, UTF8StringValidate, NULL, NULL},
377 {"( 1.3.6.1.4.1.1466.115.121.1.16 DESC 'DIT Content Rule Description' )",
378 0, NULL, NULL, NULL},
379 {"( 1.3.6.1.4.1.1466.115.121.1.17 DESC 'DIT Structure Rule Description' )",
380 0, NULL, NULL, NULL},
381 {"( 1.3.6.1.4.1.1466.115.121.1.19 DESC 'DSA Quality' )",
382 0, NULL, NULL, NULL},
383 {"( 1.3.6.1.4.1.1466.115.121.1.20 DESC 'DSE Type' )",
384 0, NULL, NULL, NULL},
385 {"( 1.3.6.1.4.1.1466.115.121.1.21 DESC 'Enhanced Guide' )",
386 0, NULL, NULL, NULL},
387 {"( 1.3.6.1.4.1.1466.115.121.1.22 DESC 'Facsimile Telephone Number' )",
388 0, NULL, NULL, NULL},
389 {"( 1.3.6.1.4.1.1466.115.121.1.23 DESC 'Fax' " X_NOT_H_R ")",
390 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
391 {"( 1.3.6.1.4.1.1466.115.121.1.24 DESC 'Generalized Time' )",
392 0, NULL, NULL, NULL},
393 {"( 1.3.6.1.4.1.1466.115.121.1.25 DESC 'Guide' )",
394 0, NULL, NULL, NULL},
395 {"( 1.3.6.1.4.1.1466.115.121.1.26 DESC 'IA5 String' )",
396 0, IA5StringValidate, NULL, NULL},
397 {"( 1.3.6.1.4.1.1466.115.121.1.27 DESC 'Integer' )",
398 0, integerValidate, NULL, NULL},
399 {"( 1.3.6.1.4.1.1466.115.121.1.28 DESC 'JPEG' " X_NOT_H_R ")",
400 SLAP_SYNTAX_BLOB, NULL, NULL, NULL},
401 {"( 1.3.6.1.4.1.1466.115.121.1.29 DESC 'Master And Shadow Access Points' )",
402 0, NULL, NULL, NULL},
403 {"( 1.3.6.1.4.1.1466.115.121.1.30 DESC 'Matching Rule Description' )",
404 0, NULL, NULL, NULL},
405 {"( 1.3.6.1.4.1.1466.115.121.1.31 DESC 'Matching Rule Use Description' )",
406 0, NULL, NULL, NULL},
407 {"( 1.3.6.1.4.1.1466.115.121.1.32 DESC 'Mail Preference' )",
408 0, NULL, NULL, NULL},
409 {"( 1.3.6.1.4.1.1466.115.121.1.33 DESC 'MHS OR Address' )",
410 0, NULL, NULL, NULL},
411 {"( 1.3.6.1.4.1.1466.115.121.1.34 DESC 'Name And Optional UID' )",
412 0, NULL, NULL, NULL},
413 {"( 1.3.6.1.4.1.1466.115.121.1.35 DESC 'Name Form Description' )",
414 0, NULL, NULL, NULL},
415 {"( 1.3.6.1.4.1.1466.115.121.1.36 DESC 'Numeric String' )",
416 0, NULL, NULL, NULL},
417 {"( 1.3.6.1.4.1.1466.115.121.1.37 DESC 'Object Class Description' )",
418 0, NULL, NULL, NULL},
419 {"( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )",
420 0, oidValidate, NULL, NULL},
421 {"( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'Other Mailbox' )",
422 0, NULL, NULL, NULL},
423 {"( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' )",
424 0, blobValidate, NULL, NULL},
425 {"( 1.3.6.1.4.1.1466.115.121.1.41 DESC 'Postal Address' )",
426 0, blobValidate, NULL, NULL},
427 {"( 1.3.6.1.4.1.1466.115.121.1.42 DESC 'Protocol Information' )",
428 0, NULL, NULL, NULL},
429 {"( 1.3.6.1.4.1.1466.115.121.1.43 DESC 'Presentation Address' )",
430 0, NULL, NULL, NULL},
431 {"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
432 0, printableStringValidate, NULL, NULL},
433 {"( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' "
434 X_BINARY X_NOT_H_R ")",
435 SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
436 {"( 1.3.6.1.4.1.1466.115.121.1.50 DESC 'Telephone Number' )",
437 0, blobValidate, NULL, NULL},
438 {"( 1.3.6.1.4.1.1466.115.121.1.51 DESC 'Teletex Terminal Identifier' )",
439 0, NULL, NULL, NULL},
440 {"( 1.3.6.1.4.1.1466.115.121.1.52 DESC 'Telex Number' )",
441 0, NULL, NULL, NULL},
442 {"( 1.3.6.1.4.1.1466.115.121.1.53 DESC 'UTC Time' )",
443 0, NULL, NULL, NULL},
444 {"( 1.3.6.1.4.1.1466.115.121.1.54 DESC 'LDAP Syntax Description' )",
445 0, NULL, NULL, NULL},
446 {"( 1.3.6.1.4.1.1466.115.121.1.55 DESC 'Modify Rights' )",
447 0, NULL, NULL, NULL},
448 {"( 1.3.6.1.4.1.1466.115.121.1.56 DESC 'LDAP Schema Definition' )",
449 0, NULL, NULL, NULL},
450 {"( 1.3.6.1.4.1.1466.115.121.1.57 DESC 'LDAP Schema Description' )",
451 0, NULL, NULL, NULL},
452 {"( 1.3.6.1.4.1.1466.115.121.1.58 DESC 'Substring Assertion' )",
453 0, NULL, NULL, NULL},
455 /* OpenLDAP Experimental Syntaxes */
456 {"( " SLAPD_OID_ACI_SYNTAX " DESC 'OpenLDAP Experimental ACI' )",
457 0, NULL, NULL, NULL},
459 {NULL, 0, NULL, NULL, NULL}
462 struct mrule_defs_rec {
465 slap_mr_convert_func * mrd_convert;
466 slap_mr_normalize_func * mrd_normalize;
467 slap_mr_match_func * mrd_match;
468 slap_mr_indexer_func * mrd_indexer;
469 slap_mr_filter_func * mrd_filter;
473 * Other matching rules in X.520 that we do not use:
475 * 2.5.13.9 numericStringOrderingMatch
476 * 2.5.13.13 booleanMatch
477 * 2.5.13.15 integerOrderingMatch
478 * 2.5.13.18 octetStringOrderingMatch
479 * 2.5.13.19 octetStringSubstringsMatch
480 * 2.5.13.25 uTCTimeMatch
481 * 2.5.13.26 uTCTimeOrderingMatch
482 * 2.5.13.31 directoryStringFirstComponentMatch
483 * 2.5.13.32 wordMatch
484 * 2.5.13.33 keywordMatch
485 * 2.5.13.34 certificateExactMatch
486 * 2.5.13.35 certificateMatch
487 * 2.5.13.36 certificatePairExactMatch
488 * 2.5.13.37 certificatePairMatch
489 * 2.5.13.38 certificateListExactMatch
490 * 2.5.13.39 certificateListMatch
491 * 2.5.13.40 algorithmIdentifierMatch
492 * 2.5.13.41 storedPrefixMatch
493 * 2.5.13.42 attributeCertificateMatch
494 * 2.5.13.43 readerAndKeyIDMatch
495 * 2.5.13.44 attributeIntegrityMatch
498 /* recycled matching functions */
499 #define caseIgnoreMatch caseIgnoreIA5Match
500 #define caseExactMatch caseExactIA5Match
502 /* unimplemented matching functions */
503 #define objectIdentifierMatch NULL
504 #define distinguishedNameMatch NULL
505 #define caseIgnoreOrderingMatch NULL
506 #define caseIgnoreSubstringsMatch NULL
507 #define caseExactOrderingMatch NULL
508 #define caseExactSubstringsMatch NULL
509 #define numericStringMatch NULL
510 #define numericStringSubstringsMatch NULL
511 #define caseIgnoreListMatch NULL
512 #define caseIgnoreListSubstringsMatch NULL
513 #define integerMatch NULL
514 #define bitStringMatch NULL
515 #define octetStringMatch NULL
516 #define telephoneNumberMatch NULL
517 #define telephoneNumberSubstringsMatch NULL
518 #define presentationAddressMatch NULL
519 #define uniqueMemberMatch NULL
520 #define protocolInformationMatch NULL
521 #define generalizedTimeMatch NULL
522 #define generalizedTimeOrderingMatch NULL
523 #define integerFirstComponentMatch NULL
524 #define objectIdentifierFirstComponentMatch NULL
525 #define caseIgnoreIA5SubstringsMatch NULL
527 struct mrule_defs_rec mrule_defs[] = {
528 {"( 2.5.13.0 NAME 'objectIdentifierMatch' "
529 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
530 SLAP_MR_EQUALITY | SLAP_MR_EXT,
531 NULL, NULL, objectIdentifierMatch, NULL, NULL},
533 {"( 2.5.13.1 NAME 'distinguishedNameMatch' "
534 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
535 SLAP_MR_EQUALITY | SLAP_MR_EXT,
536 NULL, NULL, distinguishedNameMatch, NULL, NULL},
538 {"( 2.5.13.2 NAME 'caseIgnoreMatch' "
539 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
540 SLAP_MR_EQUALITY | SLAP_MR_EXT,
541 NULL, UTF8StringNormalize, caseIgnoreMatch, NULL, NULL},
543 {"( 2.5.13.3 NAME 'caseIgnoreOrderingMatch' "
544 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
546 NULL, UTF8StringNormalize, caseIgnoreOrderingMatch, NULL, NULL},
548 {"( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' "
549 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
550 SLAP_MR_SUBSTR | SLAP_MR_EXT,
551 NULL, UTF8StringNormalize, caseIgnoreSubstringsMatch, NULL, NULL},
553 /* Next three are not in the RFC's, but are needed for compatibility */
554 {"( 2.5.13.5 NAME 'caseExactMatch' "
555 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
556 SLAP_MR_EQUALITY | SLAP_MR_EXT,
557 NULL, UTF8StringNormalize, caseExactMatch, NULL, NULL},
559 {"( 2.5.13.6 NAME 'caseExactOrderingMatch' "
560 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
562 NULL, UTF8StringNormalize, caseExactOrderingMatch, NULL, NULL},
564 {"( 2.5.13.7 NAME 'caseExactSubstringsMatch' "
565 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
566 SLAP_MR_SUBSTR | SLAP_MR_EXT,
567 NULL, UTF8StringNormalize, caseExactSubstringsMatch, NULL, NULL},
569 {"( 2.5.13.8 NAME 'numericStringMatch' "
570 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
571 SLAP_MR_EQUALITY | SLAP_MR_EXT,
572 NULL, NULL, numericStringMatch, NULL, NULL},
574 {"( 2.5.13.10 NAME 'numericStringSubstringsMatch' "
575 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
576 SLAP_MR_SUBSTR | SLAP_MR_EXT,
577 NULL, NULL, numericStringSubstringsMatch, NULL, NULL},
579 {"( 2.5.13.11 NAME 'caseIgnoreListMatch' "
580 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )",
581 SLAP_MR_EQUALITY | SLAP_MR_EXT,
582 NULL, NULL, caseIgnoreListMatch, NULL, NULL},
584 {"( 2.5.13.12 NAME 'caseIgnoreListSubstringsMatch' "
585 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
586 SLAP_MR_SUBSTR | SLAP_MR_EXT,
587 NULL, NULL, caseIgnoreListSubstringsMatch, NULL, NULL},
589 {"( 2.5.13.14 NAME 'integerMatch' "
590 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
591 SLAP_MR_NONE | SLAP_MR_EXT,
592 NULL, NULL, integerMatch, NULL, NULL},
594 {"( 2.5.13.16 NAME 'bitStringMatch' "
595 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )",
596 SLAP_MR_NONE | SLAP_MR_EXT,
597 NULL, NULL, bitStringMatch, NULL, NULL},
599 {"( 2.5.13.17 NAME 'octetStringMatch' "
600 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
601 SLAP_MR_EQUALITY | SLAP_MR_EXT,
602 NULL, NULL, octetStringMatch, NULL, NULL},
604 {"( 2.5.13.20 NAME 'telephoneNumberMatch' "
605 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )",
606 SLAP_MR_EQUALITY | SLAP_MR_EXT,
607 NULL, NULL, telephoneNumberMatch, NULL, NULL},
609 {"( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch' "
610 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
611 SLAP_MR_SUBSTR | SLAP_MR_EXT,
612 NULL, NULL, telephoneNumberSubstringsMatch, NULL, NULL},
614 {"( 2.5.13.22 NAME 'presentationAddressMatch' "
615 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )",
616 SLAP_MR_NONE | SLAP_MR_EXT,
617 NULL, NULL, presentationAddressMatch, NULL, NULL},
619 {"( 2.5.13.23 NAME 'uniqueMemberMatch' "
620 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )",
621 SLAP_MR_NONE | SLAP_MR_EXT,
622 NULL, NULL, uniqueMemberMatch, NULL, NULL},
624 {"( 2.5.13.24 NAME 'protocolInformationMatch' "
625 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )",
626 SLAP_MR_NONE | SLAP_MR_EXT,
627 NULL, NULL, protocolInformationMatch, NULL, NULL},
629 {"( 2.5.13.27 NAME 'generalizedTimeMatch' "
630 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
631 SLAP_MR_EQUALITY | SLAP_MR_EXT,
632 NULL, NULL, generalizedTimeMatch, NULL, NULL},
634 {"( 2.5.13.28 NAME 'generalizedTimeOrderingMatch' "
635 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
637 NULL, NULL, generalizedTimeOrderingMatch, NULL, NULL},
639 {"( 2.5.13.29 NAME 'integerFirstComponentMatch' "
640 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
641 SLAP_MR_EQUALITY | SLAP_MR_EXT,
642 NULL, NULL, integerFirstComponentMatch, NULL, NULL},
644 {"( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch' "
645 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
646 SLAP_MR_EQUALITY | SLAP_MR_EXT,
647 NULL, NULL, objectIdentifierFirstComponentMatch, NULL, NULL},
649 {"( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match' "
650 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
651 SLAP_MR_EQUALITY | SLAP_MR_EXT,
652 NULL, IA5StringNormalize, caseExactIA5Match, NULL, NULL},
654 {"( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match' "
655 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
656 SLAP_MR_EQUALITY | SLAP_MR_EXT,
657 NULL, IA5StringNormalize, caseIgnoreIA5Match, NULL, NULL},
659 {"( 1.3.6.1.4.1.1466.109.114.3 NAME 'caseIgnoreIA5SubstringsMatch' "
660 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
662 NULL, IA5StringNormalize, caseIgnoreIA5SubstringsMatch, NULL, NULL},
664 {NULL, SLAP_MR_NONE, NULL, NULL, NULL}
667 static int schema_init_done = 0;
675 /* we should only be called once (from main) */
676 assert( schema_init_done == 0 );
678 for ( i=0; syntax_defs[i].sd_desc != NULL; i++ ) {
679 res = register_syntax( syntax_defs[i].sd_desc,
680 syntax_defs[i].sd_flags,
681 syntax_defs[i].sd_validate,
682 syntax_defs[i].sd_ber2str,
683 syntax_defs[i].sd_str2ber );
686 fprintf( stderr, "schema_init: Error registering syntax %s\n",
687 syntax_defs[i].sd_desc );
692 for ( i=0; mrule_defs[i].mrd_desc != NULL; i++ ) {
693 if( mrule_defs[i].mrd_usage == SLAP_MR_NONE ) {
695 "schema_init: Ingoring unusable matching rule %s\n",
696 mrule_defs[i].mrd_desc );
700 res = register_matching_rule(
701 mrule_defs[i].mrd_desc,
702 mrule_defs[i].mrd_usage,
703 mrule_defs[i].mrd_convert,
704 mrule_defs[i].mrd_normalize,
705 mrule_defs[i].mrd_match,
706 mrule_defs[i].mrd_indexer,
707 mrule_defs[i].mrd_filter );
711 "schema_init: Error registering matching rule %s\n",
712 mrule_defs[i].mrd_desc );
716 schema_init_done = 1;
720 #ifdef SLAPD_SCHEMA_NOT_COMPAT
721 struct slap_internal_schema slap_schema;
723 struct slap_schema_oc_map {
727 { "alias", offsetof(struct slap_internal_schema, si_oc_alias) },
728 { "referral", offsetof(struct slap_internal_schema, si_oc_referral) },
732 struct slap_schema_ad_map {
737 offsetof(struct slap_internal_schema, si_ad_objectClass) },
740 offsetof(struct slap_internal_schema, si_ad_creatorsName) },
742 offsetof(struct slap_internal_schema, si_ad_createTimestamp) },
744 offsetof(struct slap_internal_schema, si_ad_modifiersName) },
746 offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
748 { "subschemaSubentry",
749 offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
752 offsetof(struct slap_internal_schema, si_ad_namingContexts) },
753 { "supportedControl",
754 offsetof(struct slap_internal_schema, si_ad_supportedControl) },
755 { "supportedExtension",
756 offsetof(struct slap_internal_schema, si_ad_supportedExtension) },
757 { "supportedLDAPVersion",
758 offsetof(struct slap_internal_schema, si_ad_supportedLDAPVersion) },
759 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
760 { "supportedACIMechanisms",
761 offsetof(struct slap_internal_schema, si_ad_supportedACIMechanisms) },
764 { "supportedSASLMechanisms",
765 offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) },
768 offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
770 offsetof(struct slap_internal_schema, si_ad_ldapSyntaxes) },
772 offsetof(struct slap_internal_schema, si_ad_matchingRules) },
774 offsetof(struct slap_internal_schema, si_ad_objectClasses) },
777 offsetof(struct slap_internal_schema, si_ad_ref) },
780 offsetof(struct slap_internal_schema, si_ad_entry) },
782 offsetof(struct slap_internal_schema, si_ad_children) },
785 offsetof(struct slap_internal_schema, si_ad_userPassword) },
787 offsetof(struct slap_internal_schema, si_ad_authPassword) },
788 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
790 offsetof(struct slap_internal_schema, si_ad_krbName) },
801 #ifdef SLAPD_SCHEMA_NOT_COMPAT
804 /* we should only be called once after schema_init() was called */
805 assert( schema_init_done == 1 );
807 #ifdef SLAPD_SCHEMA_NOT_COMPAT
808 for( i=0; oc_map[i].ssom_name; i++ ) {
809 ObjectClass ** ocp = (ObjectClass **)
810 &(((char *) &slap_schema)[oc_map[i].ssom_offset]);
812 *ocp = oc_find( oc_map[i].ssom_name );
816 "No objectClass \"%s\" defined in schema\n",
817 oc_map[i].ssom_name );
818 return LDAP_OBJECT_CLASS_VIOLATION;
822 for( i=0; ad_map[i].ssam_name; i++ ) {
826 AttributeDescription ** adp = (AttributeDescription **)
827 &(((char *) &slap_schema)[ad_map[i].ssam_offset]);
831 rc = slap_str2ad( ad_map[i].ssam_name, adp, &text );
833 if( rc != LDAP_SUCCESS ) {
835 "No attribute \"%s\" defined in schema\n",
836 ad_map[i].ssam_name );