- pEntry = (Entry *) ch_calloc( 1, sizeof(Entry) );
- if ( pEntry == NULL) {
- rc = LDAP_NO_MEMORY;
- goto cleanup;
- }
-
- dn.bv_val = slapi_ch_strdup(ldn);
- dn.bv_len = strlen(ldn);
-
- rc = dnPrettyNormal( NULL, &dn, &pEntry->e_name, &pEntry->e_nname );
- if (rc != LDAP_SUCCESS) goto cleanup;
-
- if ( rc == LDAP_SUCCESS ) {
- for ( i=0, pMod=mods[0]; rc == LDAP_SUCCESS && pMod != NULL; pMod=mods[++i]) {
- Modifications *mod;
- if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) {
- /* attr values are in berval format */
- /* convert an array of pointers to bervals to an array of bervals */
- rc = bvptr2obj(pMod->mod_bvalues, &bv);
- if (rc != LDAP_SUCCESS) goto cleanup;
- tmp.sml_type.bv_val = pMod->mod_type;
- tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_bvalues = bv;
-#ifdef SLAP_NVALUES
- tmp.sml_nvalues = NULL;
-#endif
-
- mod = (Modifications *) ch_malloc( sizeof(Modifications) );
-
- mod->sml_op = LDAP_MOD_ADD;
- mod->sml_next = NULL;
- mod->sml_desc = NULL;
- mod->sml_type = tmp.sml_type;
- mod->sml_bvalues = tmp.sml_bvalues;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = tmp.sml_nvalues;
-#endif
-
- *modtail = mod;
- modtail = &mod->sml_next;
-
- } else {
- /* attr values are in string format, need to be converted */
- /* to an array of bervals */
- if ( pMod->mod_values == NULL ) {
- rc = LDAP_OTHER;
- } else {
- rc = values2obj( pMod->mod_values, &bv );
- if (rc != LDAP_SUCCESS) goto cleanup;
- tmp.sml_type.bv_val = pMod->mod_type;
- tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_bvalues = bv;
-#ifdef SLAP_NVALUES
- tmp.sml_nvalues = NULL;
-#endif
-
- mod = (Modifications *) ch_malloc( sizeof(Modifications) );
-
- mod->sml_op = LDAP_MOD_ADD;
- mod->sml_next = NULL;
- mod->sml_desc = NULL;
- mod->sml_type = tmp.sml_type;
- mod->sml_bvalues = tmp.sml_bvalues;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = tmp.sml_nvalues;
-#endif
-
- *modtail = mod;
- modtail = &mod->sml_next;
- }
- }
- } /* for each LDAPMod */
- }