/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2005 The OpenLDAP Foundation.
+ * Copyright 1998-2006 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
a = LDAP_STAILQ_FIRST(&attr_list);
LDAP_STAILQ_REMOVE_HEAD(&attr_list, sat_next);
- if (a->sat_subtypes) ldap_memfree(a->sat_subtypes);
+ if ( a->sat_equality ) {
+ MatchingRule *mr;
+
+ mr = mr_find( a->sat_equality->smr_oid );
+ assert( mr != NULL );
+ if ( mr != a->sat_equality ) {
+ ch_free( a->sat_equality );
+ a->sat_equality = NULL;
+ }
+ }
+
+ assert( a->sat_syntax != NULL );
+ if ( a->sat_syntax != NULL ) {
+ Syntax *syn;
+
+ syn = syn_find( a->sat_syntax->ssyn_oid );
+ assert( syn != NULL );
+ if ( syn != a->sat_syntax ) {
+ ch_free( a->sat_syntax );
+ a->sat_syntax = NULL;
+ }
+ }
+
+ if ( a->sat_oidmacro ) ldap_memfree( a->sat_oidmacro );
+ if ( a->sat_subtypes ) ldap_memfree( a->sat_subtypes );
ad_destroy(a->sat_ad);
ldap_pvt_thread_mutex_destroy(&a->sat_ad_mutex);
ldap_attributetype_free((LDAPAttributeType *)a);
if ( slap_schema.si_at_undefined ) {
ad_destroy(slap_schema.si_at_undefined->sat_ad);
}
+
+ if ( slap_schema.si_at_proxied ) {
+ ad_destroy(slap_schema.si_at_proxied->sat_ad);
+ }
}
int
const char **err )
{
struct aindexrec *air;
- char **names;
+ char **names = NULL;
if ( sat->sat_oid ) {
air = (struct aindexrec *)
ch_calloc( 1, sizeof(struct aindexrec) );
- air->air_name.bv_val = sat->sat_oid;
- air->air_name.bv_len = strlen(sat->sat_oid);
+ ber_str2bv( sat->sat_oid, 0, 0, &air->air_name );
air->air_at = sat;
if ( avl_insert( &attr_index, (caddr_t) air,
attr_index_cmp, avl_dup_error ) )
while ( *names ) {
air = (struct aindexrec *)
ch_calloc( 1, sizeof(struct aindexrec) );
- air->air_name.bv_val = *names;
- air->air_name.bv_len = strlen(*names);
+ ber_str2bv( *names, 0, 0, &air->air_name );
air->air_at = sat;
if ( avl_insert( &attr_index, (caddr_t) air,
attr_index_cmp, avl_dup_error ) )
ldap_memfree(air);
+ while ( names > sat->sat_names ) {
+ struct aindexrec tmpair;
+
+ names--;
+ ber_str2bv( *names, 0, 0, &tmpair.air_name );
+ tmpair.air_at = sat;
+ air = (struct aindexrec *)avl_delete( &attr_index,
+ (caddr_t)&tmpair, attr_index_cmp );
+ assert( air != NULL );
+ ldap_memfree( air );
+ }
+
+ if ( sat->sat_oid ) {
+ struct aindexrec tmpair;
+
+ ber_str2bv( sat->sat_oid, 0, 0, &tmpair.air_name );
+ tmpair.air_at = sat;
+ air = (struct aindexrec *)avl_delete( &attr_index,
+ (caddr_t)&tmpair, attr_index_cmp );
+ assert( air != NULL );
+ ldap_memfree( air );
+ }
+
return rc;
}
/* FIX: temporal consistency check */
}
}
+ if ( sat->sat_oid ) {
+ slap_ad_undef_promote( sat->sat_oid, sat );
+ }
+
+ names = sat->sat_names;
+ if ( names ) {
+ while ( *names ) {
+ slap_ad_undef_promote( *names, sat );
+ names++;
+ }
+ }
+
LDAP_STAILQ_INSERT_TAIL( &attr_list, sat, sat_next );
return 0;
int
at_add(
- LDAPAttributeType *at,
- int user,
- AttributeType **rsat,
- const char **err )
+ LDAPAttributeType *at,
+ int user,
+ AttributeType **rsat,
+ const char **err )
{
- AttributeType *sat;
- MatchingRule *mr;
- Syntax *syn;
+ AttributeType *sat = NULL;
+ MatchingRule *mr = NULL;
+ Syntax *syn = NULL;
int i;
- int code;
- char *cname;
- char *oid;
- char *oidm = NULL;
+ int code = LDAP_SUCCESS;
+ char *cname = NULL;
+ char *oidm = NULL;
+
+ if ( !at->at_oid ) {
+ *err = "";
+ return SLAP_SCHERR_ATTR_INCOMPLETE;
+ }
if ( !OID_LEADCHAR( at->at_oid[0] )) {
+ char *oid;
+
/* Expand OID macros */
oid = oidm_find( at->at_oid );
if ( !oid ) {
}
if ( at->at_syntax_oid && !OID_LEADCHAR( at->at_syntax_oid[0] )) {
+ char *oid;
+
/* Expand OID macros */
oid = oidm_find( at->at_syntax_oid );
if ( !oid ) {
*err = at->at_syntax_oid;
- return SLAP_SCHERR_OIDM;
+ code = SLAP_SCHERR_OIDM;
+ goto error_return;
}
if ( oid != at->at_syntax_oid ) {
ldap_memfree( at->at_syntax_oid );
for( i=0; at->at_names[i]; i++ ) {
if( !slap_valid_descr( at->at_names[i] ) ) {
*err = at->at_names[i];
- return SLAP_SCHERR_BAD_DESCR;
+ code = SLAP_SCHERR_BAD_DESCR;
+ goto error_return;
}
}
cname = at->at_names[0];
- } else if ( at->at_oid ) {
+ } else {
cname = at->at_oid;
- } else {
- *err = "";
- return SLAP_SCHERR_ATTR_INCOMPLETE;
}
*err = cname;
if ( !at->at_usage && at->at_no_user_mod ) {
/* user attribute must be modifable */
- return SLAP_SCHERR_ATTR_BAD_USAGE;
+ code = SLAP_SCHERR_ATTR_BAD_USAGE;
+ goto error_return;
}
if ( at->at_collective ) {
if( at->at_usage ) {
/* collective attributes cannot be operational */
- return SLAP_SCHERR_ATTR_BAD_USAGE;
+ code = SLAP_SCHERR_ATTR_BAD_USAGE;
+ goto error_return;
}
if( at->at_single_value ) {
/* collective attributes cannot be single-valued */
- return SLAP_SCHERR_ATTR_BAD_USAGE;
+ code = SLAP_SCHERR_ATTR_BAD_USAGE;
+ goto error_return;
}
}
ch_free( sat );
}
+ if ( oidm ) {
+ SLAP_FREE( at->at_oid );
+ at->at_oid = oidm;
+ }
+
} else if ( rsat ) {
*rsat = sat;
}
}
#ifdef LDAP_DEBUG
+#ifdef SLAPD_UNUSED
static int
at_index_printnode( void *v_air, void *ignore )
{
(void) avl_apply( attr_index, at_index_printnode, 0, -1, AVL_INORDER );
}
#endif
+#endif
void
at_unparse( BerVarray *res, AttributeType *start, AttributeType *end, int sys )