*ad = *desc;
- ad->ad_cname = ber_bvdup( ad->ad_cname );
- ad->ad_lang = ch_strdup( ad->ad_lang );
+ if( ad->ad_cname != NULL ) {
+ ad->ad_cname = ber_bvdup( ad->ad_cname );
+ }
+
+ if( ad->ad_lang != NULL ) {
+ ad->ad_lang = ch_strdup( ad->ad_lang );
+ }
return ad;
}
{
if( ad == NULL ) return;
- ber_bvfree( ad->ad_cname );
+ if( ad->ad_cname != NULL ) {
+ ber_bvfree( ad->ad_cname );
+ }
+
free( ad->ad_lang );
if( freeit ) free( ad );
int slap_str2ad(
const char *str,
AttributeDescription **ad,
- char **text )
+ const char **text )
{
struct berval bv;
bv.bv_val = (char *) str;
int slap_bv2ad(
struct berval *bv,
AttributeDescription **ad,
- char **text )
+ const char **text )
{
int rtn = LDAP_UNDEFINED_TYPE;
int i;
char **tokens;
assert( ad != NULL );
- assert( *text != NULL );
+ assert( *ad == NULL ); /* temporary */
if( bv == NULL || bv->bv_len == 0 ) {
*text = "empty attribute description";
for( i=1; tokens[i] != NULL; i++ ) {
if( strcasecmp( tokens[i], "binary" ) == 0 ) {
- if( desc.ad_flags & SLAP_DESC_BINARY ) {
+ if( slap_ad_is_binary( &desc ) ) {
*text = "option \"binary\" specified multiple times";
goto done;
}
- if(!( desc.ad_type->sat_syntax->ssyn_flags
- & SLAP_SYNTAX_BINARY ))
- {
+ if( !slap_syntax_is_binary( desc.ad_type->sat_syntax )) {
/* not stored in binary, disallow option */
*text = "option \"binary\" with type not supported";
goto done;
*text = "multiple language tag options specified";
goto done;
}
+
desc.ad_lang = tokens[i];
/* normalize to all lower case, it's easy */
desc.ad_cname = ch_malloc( sizeof( struct berval ) );
desc.ad_cname->bv_len = strlen( desc.ad_type->sat_cname );
- if( desc.ad_flags & SLAP_DESC_BINARY ) {
+ if( slap_ad_is_binary( &desc ) ) {
desc.ad_cname->bv_len += sizeof("binary");
}
if( desc.ad_lang != NULL ) {
desc.ad_cname->bv_val = ch_malloc( desc.ad_cname->bv_len + 1 );
strcpy( desc.ad_cname->bv_val, desc.ad_type->sat_cname );
- if( desc.ad_flags & SLAP_DESC_BINARY ) {
+ if( slap_ad_is_binary( &desc ) ) {
strcat( desc.ad_cname->bv_val, ";binary" );
}
int i;
for( i=0; attrs[i] != NULL; i++ ) {
AttributeDescription *ad = NULL;
- char *text;
+ const char *text;
int rc;
rc = slap_str2ad( attrs[i], &ad, &text );