- return( -1 );
-}
-
-static int
-add_values(
- Entry *e,
- Modification *mod,
- char *dn
-)
-{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- /* not yet implemented */
-#else
- int i;
- Attribute *a;
-
- /* check if the values we're adding already exist */
- if ( (a = attr_find( e->e_attrs, mod->mod_type )) != NULL ) {
- for ( i = 0; mod->mod_bvalues[i] != NULL; i++ ) {
- if ( value_find( a->a_vals, mod->mod_bvalues[i],
- a->a_syntax, 3 ) == 0 ) {
- return( LDAP_TYPE_OR_VALUE_EXISTS );
- }
- }
- }
-
- /* no - add them */
- if( attr_merge( e, mod->mod_type, mod->mod_bvalues ) != 0 ) {
- return( LDAP_CONSTRAINT_VIOLATION );
- }
-#endif
-
- return( LDAP_SUCCESS );
-}
-
-static int
-delete_values(
- Entry *e,
- Modification *mod,
- char *dn
-)
-{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- /* not yet implemented */
-#else
- int i, j, k, found;
- Attribute *a;
-
- /* delete the entire attribute */
- if ( mod->mod_bvalues == NULL ) {
- Debug( LDAP_DEBUG_ARGS, "removing entire attribute %s\n",
- mod->mod_type, 0, 0 );
- return( attr_delete( &e->e_attrs, mod->mod_type ) ?
- LDAP_NO_SUCH_ATTRIBUTE : LDAP_SUCCESS );
- }
-
- /* delete specific values - find the attribute first */
- if ( (a = attr_find( e->e_attrs, mod->mod_type )) == NULL ) {
- Debug( LDAP_DEBUG_ARGS, "could not find attribute %s\n",
- mod->mod_type, 0, 0 );
- return( LDAP_NO_SUCH_ATTRIBUTE );
- }
-
- /* find each value to delete */
- for ( i = 0; mod->mod_bvalues[i] != NULL; i++ ) {
- found = 0;
- for ( j = 0; a->a_vals[j] != NULL; j++ ) {
- if ( value_cmp( mod->mod_bvalues[i], a->a_vals[j],
- a->a_syntax, 3 ) != 0 ) {
- continue;
- }
- found = 1;
-
- /* found a matching value - delete it */
- ber_bvfree( a->a_vals[j] );
- for ( k = j + 1; a->a_vals[k] != NULL; k++ ) {
- a->a_vals[k - 1] = a->a_vals[k];
- }
- a->a_vals[k - 1] = NULL;
-
- /* delete the entire attribute, if no values remain */
- if ( a->a_vals[0] == NULL) {
- Debug( LDAP_DEBUG_ARGS,
- "removing entire attribute %s\n",
- mod->mod_type, 0, 0 );
- if ( attr_delete( &e->e_attrs, mod->mod_type ) ) {
- return LDAP_NO_SUCH_ATTRIBUTE;
- }
- }
-
- break;
- }
-
- /* looked through them all w/o finding it */
- if ( ! found ) {
- Debug( LDAP_DEBUG_ARGS,
- "could not find value for attr %s\n",
- mod->mod_type, 0, 0 );
- return( LDAP_NO_SUCH_ATTRIBUTE );
- }
- }
-#endif
-
- return( LDAP_SUCCESS );
-}
-
-static int
-replace_values(
- Entry *e,
- Modification *mod,
- char *dn
-)
-{
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- /* not yet implemented */
-#else
- (void) attr_delete( &e->e_attrs, mod->mod_type );
-
- if ( mod->mod_bvalues != NULL &&
- attr_merge( e, mod->mod_type, mod->mod_bvalues ) != 0 )
- {
- return( LDAP_CONSTRAINT_VIOLATION );
- }
-#endif
-
- return( LDAP_SUCCESS );