From: Kurt Zeilenga Date: Tue, 25 Jan 2000 00:38:48 +0000 (+0000) Subject: Start putting old code behind the currently defined SLAPD_SCHEMA_COMPAT. X-Git-Tag: UCDATA_2_4~5 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7f63755d5d6ae65222882c84f5bdd9dc36dc5daa;p=openldap Start putting old code behind the currently defined SLAPD_SCHEMA_COMPAT. --- diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index 4d94aced30..74407d493c 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -266,6 +266,7 @@ attr_syntax_config( char **argv ) { +#ifdef SLAPD_SCHEMA_COMPAT char *save; LDAP_ATTRIBUTE_TYPE *at; int lasti; @@ -344,8 +345,14 @@ attr_syntax_config( exit( EXIT_FAILURE ); } ldap_memfree(at); +#else + fprintf( stderr, "%s: line %d: %s\n", + fname, lineno, "not built with -DSLAPD_SCHEMA_COMPAT\n"); + exit( EXIT_FAILURE ); +#endif } +#ifdef SLAPD_SCHEMA_COMPAT int at_fake_if_needed( char *name @@ -363,6 +370,7 @@ at_fake_if_needed( return 0; } } +#endif struct aindexrec { char *air_name; @@ -407,14 +415,17 @@ at_find( tmpname = ch_malloc( p-name+1 ); strncpy( tmpname, name, p-name ); tmpname[p-name] = '\0'; - } else + } else { tmpname = (char *)name; + } + if ( (air = (struct aindexrec *) avl_find( attr_index, tmpname, (AVL_CMP) attr_index_name_cmp )) != NULL ) { if ( tmpname != name ) ldap_memfree( tmpname ); return( air->air_at ); } + if ( tmpname != name ) ldap_memfree( tmpname ); return( NULL ); @@ -621,6 +632,7 @@ at_add( return SLAP_SCHERR_SYN_NOT_FOUND; } +#ifdef SLAPD_SCHEMA_COMPAT if ( !strcmp(at->at_syntax_oid, SYNTAX_DS_OID) ) { if ( at->at_equality_oid && ( !strcmp(at->at_equality_oid, SYNTAX_DSCE_OID) ) ) @@ -651,6 +663,7 @@ at_add( } else { sat->sat_syntax_compat = DEFAULT_SYNTAX; } +#endif } else if ( sat->sat_syntax == NULL ) { return SLAP_SCHERR_ATTR_INCOMPLETE; @@ -695,30 +708,22 @@ at_canonical_name( char * a_type ) AttributeType *atp; if ( (atp=at_find(a_type)) == NULL ) { - return a_type; - } else if ( atp->sat_names - && atp->sat_names[0] - && (*(atp->sat_names[0]) != '\0') ) { - + } else if ( atp->sat_names + && atp->sat_names[0] && (*(atp->sat_names[0]) != '\0') ) + { return atp->sat_names[0]; } else if (atp->sat_oid && (*atp->sat_oid != '\0')) { - return atp->sat_oid; } else { - return a_type; - } - -}/* char * at_canonica_name() */ - +} #if defined( SLAPD_SCHEMA_DN ) - int at_schema_info( Entry *e ) { @@ -746,12 +751,13 @@ at_schema_info( Entry *e ) #endif #ifdef LDAP_DEBUG - static int at_index_printnode( struct aindexrec *air ) { - printf( "%s = %s\n", air->air_name, ldap_attributetype2str(&air->air_at->sat_atype) ); + printf("%s = %s\n", + air->air_name, + ldap_attributetype2str(&air->air_at->sat_atype) ); return( 0 ); } @@ -762,5 +768,4 @@ at_index_print( void ) (void) avl_apply( attr_index, (AVL_APPLY) at_index_printnode, 0, -1, AVL_INORDER ); } - #endif diff --git a/servers/slapd/schemaparse.c b/servers/slapd/schemaparse.c index e001c98254..48249d3f75 100644 --- a/servers/slapd/schemaparse.c +++ b/servers/slapd/schemaparse.c @@ -57,6 +57,7 @@ parse_oc_old( char **argv ) { +#ifdef SLAPD_SCHEMA_COMPAT int i; char last; LDAP_OBJECT_CLASS *oc; @@ -117,27 +118,23 @@ parse_oc_old( * out of thin air. */ if ( oc->oc_at_oids_must ) { - namep = oc->oc_at_oids_must; - while ( *namep ) { + for( namep = oc->oc_at_oids_must; *namep ; namep++ ) { code = at_fake_if_needed( *namep ); if ( code ) { fprintf( stderr, "%s: line %d: %s %s\n", fname, lineno, scherr2str(code), *namep); exit( EXIT_FAILURE ); } - namep++; } } if ( oc->oc_at_oids_may ) { - namep = oc->oc_at_oids_may; - while ( *namep ) { + for( namep = oc->oc_at_oids_may; *namep; namep++ ) { code = at_fake_if_needed( *namep ); if ( code ) { fprintf( stderr, "%s: line %d: %s %s\n", fname, lineno, scherr2str(code), *namep); exit( EXIT_FAILURE ); } - namep++; } } @@ -148,6 +145,12 @@ parse_oc_old( exit( EXIT_FAILURE ); } ldap_memfree(oc); + +#else + fprintf( stderr, "%s: line %d: %s %s\n", + fname, lineno, "not built with -DSLAPD_SCHEMA_COMPAT\n"); + exit( EXIT_FAILURE ); +#endif } /* OID Macros */ diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 64d3b14497..f96e38d787 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -8,6 +8,8 @@ #ifndef _SLDAPD_H_ #define _SLDAPD_H_ +#define SLAPD_SCHEMA_COMPAT 1 + #include "ldap_defaults.h" #include @@ -85,6 +87,14 @@ LDAP_BEGIN_DECL #define NEEDSESCAPE(c) ((c) == '\\' || (c) == '"') +#define SLAPD_ACI_DEFAULT_ATTR "aci" + +LIBSLAPD_F (int) slap_debug; + + +/* + * represents schema information for a database + */ #define SLAP_SCHERR_OUTOFMEM 1 #define SLAP_SCHERR_CLASS_NOT_FOUND 2 #define SLAP_SCHERR_ATTR_NOT_FOUND 3 @@ -98,9 +108,87 @@ LDAP_BEGIN_DECL #define SLAP_SCHERR_SYN_NOT_FOUND 11 #define SLAP_SCHERR_MR_INCOMPLETE 12 -#define SLAPD_ACI_DEFAULT_ATTR "aci" +typedef struct slap_oid_macro { + struct slap_oid_macro *next; + char *name; + char *oid; + int oidlen; +} OidMacro; + +typedef int slap_syntax_validate_func LDAP_P(( + struct berval * in)); + +typedef int slap_syntax_normalize_func LDAP_P(( + struct berval * in, + struct berval ** out)); + +typedef struct slap_syntax { + LDAP_SYNTAX ssyn_syn; + slap_syntax_validate_func *ssyn_validate; + slap_syntax_normalize_func *ssyn_normalize; + struct slap_syntax *ssyn_next; +#define ssyn_oid ssyn_syn.syn_oid +#define ssyn_desc ssyn_syn.syn_desc +} Syntax; + +typedef int slap_mr_match_func LDAP_P(( + struct berval * atval, + struct berval * matchval)); + +typedef struct slap_matching_rule { + LDAP_MATCHING_RULE smr_mrule; + slap_mr_match_func *smr_match; + Syntax *smr_syntax; + struct slap_matching_rule *smr_next; +#define smr_oid smr_mrule.mr_oid +#define smr_names smr_mrule.mr_names +#define smr_desc smr_mrule.mr_desc +#define smr_obsolete smr_mrule.mr_obsolete +#define smr_syntax_oid smr_mrule.mr_syntax_oid +} MatchingRule; + +typedef struct slap_attribute_type { + LDAP_ATTRIBUTE_TYPE sat_atype; + struct slap_attribute_type *sat_sup; + struct slap_attribute_type **sat_subtypes; + MatchingRule *sat_equality; + MatchingRule *sat_ordering; + MatchingRule *sat_substr; + Syntax *sat_syntax; + /* The next one is created to help in the transition */ + int sat_syntax_compat; + struct slap_attribute_type *sat_next; +#define sat_oid sat_atype.at_oid +#define sat_names sat_atype.at_names +#define sat_desc sat_atype.at_desc +#define sat_obsolete sat_atype.at_obsolete +#define sat_sup_oid sat_atype.at_sup_oid +#define sat_equality_oid sat_atype.at_equality_oid +#define sat_ordering_oid sat_atype.at_ordering_oid +#define sat_substr_oid sat_atype.at_substr_oid +#define sat_syntax_oid sat_atype.at_syntax_oid +#define sat_single_value sat_atype.at_single_value +#define sat_collective sat_atype.at_collective +#define sat_no_user_mods sat_atype.at_no_user_mods +#define sat_usage sat_atype.at_usage +} AttributeType; + +typedef struct slap_object_class { + LDAP_OBJECT_CLASS soc_oclass; + struct slap_object_class **soc_sups; + AttributeType **soc_required; + AttributeType **soc_allowed; + struct slap_object_class *soc_next; +#define soc_oid soc_oclass.oc_oid +#define soc_names soc_oclass.oc_names +#define soc_desc soc_oclass.oc_desc +#define soc_obsolete soc_oclass.oc_obsolete +#define soc_sup_oids soc_oclass.oc_sup_oids +#define soc_kind soc_oclass.oc_kind +#define soc_at_oids_must soc_oclass.oc_at_oids_must +#define soc_at_oids_may soc_oclass.oc_at_oids_may +} ObjectClass; -LIBSLAPD_F (int) slap_debug; struct slap_op; struct slap_conn; @@ -182,10 +270,13 @@ typedef struct slap_filter { typedef struct slap_attr { char *a_type; /* description */ struct berval **a_vals; +#ifdef SLAPD_SCHEMA_COMPAT int a_syntax; +#endif struct slap_attr *a_next; } Attribute; +#ifdef SLAPD_SCHEMA_COMPAT /* * the attr_syntax() routine returns one of these values * telling what kind of syntax an attribute supports. @@ -195,6 +286,7 @@ typedef struct slap_attr { #define SYNTAX_BIN 0x04 /* binary data */ #define SYNTAX_TEL 0x08 /* telephone number string */ #define SYNTAX_DN 0x10 /* dn string */ +#endif /* * the id used in the indexes to refer to an entry @@ -355,90 +447,6 @@ typedef struct ldapmodlist { #define ml_bvalues ml_mod.mod_bvalues } LDAPModList; -/* - * represents schema information for a database - */ -typedef struct slap_oid_macro { - struct slap_oid_macro *next; - char *name; - char *oid; - int oidlen; -} OidMacro; - -typedef int slap_syntax_validate_func LDAP_P(( - struct berval * in)); - -typedef int slap_syntax_normalize_func LDAP_P(( - struct berval * in, - struct berval ** out)); - -typedef struct slap_syntax { - LDAP_SYNTAX ssyn_syn; - slap_syntax_validate_func *ssyn_validate; - slap_syntax_normalize_func *ssyn_normalize; - struct slap_syntax *ssyn_next; -#define ssyn_oid ssyn_syn.syn_oid -#define ssyn_desc ssyn_syn.syn_desc -} Syntax; - -typedef int slap_mr_match_func LDAP_P(( - struct berval * atval, - struct berval * matchval)); - -typedef struct slap_matching_rule { - LDAP_MATCHING_RULE smr_mrule; - slap_mr_match_func *smr_match; - Syntax *smr_syntax; - struct slap_matching_rule *smr_next; -#define smr_oid smr_mrule.mr_oid -#define smr_names smr_mrule.mr_names -#define smr_desc smr_mrule.mr_desc -#define smr_obsolete smr_mrule.mr_obsolete -#define smr_syntax_oid smr_mrule.mr_syntax_oid -} MatchingRule; - -typedef struct slap_attribute_type { - LDAP_ATTRIBUTE_TYPE sat_atype; - struct slap_attribute_type *sat_sup; - struct slap_attribute_type **sat_subtypes; - MatchingRule *sat_equality; - MatchingRule *sat_ordering; - MatchingRule *sat_substr; - Syntax *sat_syntax; - /* The next one is created to help in the transition */ - int sat_syntax_compat; - struct slap_attribute_type *sat_next; -#define sat_oid sat_atype.at_oid -#define sat_names sat_atype.at_names -#define sat_desc sat_atype.at_desc -#define sat_obsolete sat_atype.at_obsolete -#define sat_sup_oid sat_atype.at_sup_oid -#define sat_equality_oid sat_atype.at_equality_oid -#define sat_ordering_oid sat_atype.at_ordering_oid -#define sat_substr_oid sat_atype.at_substr_oid -#define sat_syntax_oid sat_atype.at_syntax_oid -#define sat_single_value sat_atype.at_single_value -#define sat_collective sat_atype.at_collective -#define sat_no_user_mods sat_atype.at_no_user_mods -#define sat_usage sat_atype.at_usage -} AttributeType; - -typedef struct slap_object_class { - LDAP_OBJECT_CLASS soc_oclass; - struct slap_object_class **soc_sups; - AttributeType **soc_required; - AttributeType **soc_allowed; - struct slap_object_class *soc_next; -#define soc_oid soc_oclass.oc_oid -#define soc_names soc_oclass.oc_names -#define soc_desc soc_oclass.oc_desc -#define soc_obsolete soc_oclass.oc_obsolete -#define soc_sup_oids soc_oclass.oc_sup_oids -#define soc_kind soc_oclass.oc_kind -#define soc_at_oids_must soc_oclass.oc_at_oids_must -#define soc_at_oids_may soc_oclass.oc_at_oids_may -} ObjectClass; - /* * Backend-info * represents a backend