char *s,
int flags )
{
- Slapi_Entry *e = NULL;
- char *pTmpS;
-
- pTmpS = slapi_ch_strdup( s );
- if ( pTmpS != NULL ) {
- e = str2entry( pTmpS );
- slapi_ch_free( (void **)&pTmpS );
- }
-
- return e;
+ return str2entry( s );
}
char *
Slapi_Entry *e,
int *len )
{
- char *ret;
+ char *ret = NULL;
+ char *s;
ldap_pvt_thread_mutex_lock( &entry2str_mutex );
- ret = entry2str( e, len );
+ s = entry2str( e, len );
+ if ( s != NULL )
+ ret = slapi_ch_strdup( s );
ldap_pvt_thread_mutex_unlock( &entry2str_mutex );
return ret;
BerVarray bv;
int rc;
- rc = bvptr2obj( vals, &bv );
+ rc = slap_str2ad( type, &ad, &text );
if ( rc != LDAP_SUCCESS ) {
return -1;
}
- rc = slap_str2ad( type, &ad, &text );
+ rc = bvptr2obj( vals, &bv );
if ( rc != LDAP_SUCCESS ) {
return -1;
}
p = slapi_value_get_string( &attr->a_vals[0] );
if ( p != NULL ) {
- return slapi_ch_strdup( (char *)p );
+ return slapi_ch_strdup( p );
}
}
{
struct berval dn, prettyDN;
struct berval parentDN;
+ char *ret;
if ( _dn == NULL ) {
return NULL;
dnParent( &prettyDN, &parentDN ); /* in-place */
- slapi_ch_free( (void **)&prettyDN.bv_val );
-
if ( parentDN.bv_len == 0 ) {
+ slapi_ch_free_string( &prettyDN.bv_val );
return NULL;
}
- return slapi_ch_strdup( parentDN.bv_val );
+ ret = slapi_ch_strdup( parentDN.bv_val );
+ slapi_ch_free_string( &prettyDN.bv_val );
+
+ return ret;
}
int slapi_dn_isbesuffix( Slapi_PBlock *pb, char *ldn )
}
char *
-slapi_ch_strdup( char *s )
+slapi_ch_strdup( const char *s )
{
- return ch_strdup( (const char *)s );
+ return ch_strdup( s );
}
size_t
-slapi_ch_stlen( char *s )
+slapi_ch_stlen( const char *s )
{
- return strlen( (const char *)s );
+ return strlen( s );
}
int
Slapi_Value *slapi_value_init_string(Slapi_Value *v, const char *s)
{
- v->bv_val = slapi_ch_strdup( (char *)s );
+ v->bv_val = slapi_ch_strdup( s );
v->bv_len = strlen( s );
return v;
/*
* Synthesise an LDAPMod array from a Modifications list to pass
- * to SLAPI. This synthesis is destructive and as such the
- * Modifications list may not be used after calling this
- * function.
- *
- * This function must also be called before slap_mods_check().
+ * to SLAPI.
*/
-LDAPMod **slapi_int_modifications2ldapmods( Modifications **pmodlist )
+LDAPMod **slapi_int_modifications2ldapmods( Modifications *modlist )
{
- Modifications *ml, *modlist;
+ Modifications *ml;
LDAPMod **mods, *modp;
int i, j;
- modlist = *pmodlist;
-
for( i = 0, ml = modlist; ml != NULL; i++, ml = ml->sml_next )
;
mods[i] = (LDAPMod *)slapi_ch_malloc( sizeof(LDAPMod) );
modp = mods[i];
modp->mod_op = ml->sml_op | LDAP_MOD_BVALUES;
- modp->mod_type = slapi_ch_strdup( ml->sml_type.bv_val );
- ml->sml_type.bv_val = NULL;
+ if ( BER_BVISNULL( &ml->sml_type ) ) {
+ /* may happen for internally generated mods */
+ assert( ml->sml_desc != NULL );
+ modp->mod_type = slapi_ch_strdup( ml->sml_desc->ad_cname.bv_val );
+ } else {
+ modp->mod_type = slapi_ch_strdup( ml->sml_type.bv_val );
+ BER_BVZERO( &ml->sml_type );
+ }
if ( ml->sml_values != NULL ) {
for( j = 0; ml->sml_values[j].bv_val != NULL; j++ )
for( j = 0; ml->sml_values[j].bv_val != NULL; j++ ) {
modp->mod_bvalues[j] = (struct berval *)slapi_ch_malloc(
sizeof(struct berval) );
- /* Take ownership of original values. */
- modp->mod_bvalues[j]->bv_len = ml->sml_values[j].bv_len;
- modp->mod_bvalues[j]->bv_val = ml->sml_values[j].bv_val;
- ml->sml_values[j].bv_len = 0;
- ml->sml_values[j].bv_val = NULL;
+ ber_dupbv( modp->mod_bvalues[j], &ml->sml_values[j] );
}
modp->mod_bvalues[j] = NULL;
- slapi_ch_free( (void **)&ml->sml_values );
} else {
modp->mod_bvalues = NULL;
}
mods[i] = NULL;
- slap_mods_free( modlist, 1 );
- *pmodlist = NULL;
-
return mods;
}
return be->be_update_ndn.bv_val;
}
+Slapi_Backend *slapi_be_select( const Slapi_DN *sdn )
+{
+ Slapi_Backend *be;
+
+ slapi_sdn_get_ndn( sdn );
+
+ be = select_backend( (struct berval *)&sdn->ndn, 0, 0 );
+
+ return be;
+}
+
#if 0
void
slapi_operation_set_flag(Slapi_Operation *op, unsigned long flag)