ldap_objectclass2str LDAP_P((
LDAPObjectClass * oc ));
+LDAP_F( struct berval * )
+ldap_objectclass2bv LDAP_P((
+ LDAPObjectClass * oc, struct berval *bv ));
+
LDAP_F( char * )
ldap_attributetype2str LDAP_P((
LDAPAttributeType * at ));
+LDAP_F( struct berval * )
+ldap_attributetype2bv LDAP_P((
+ LDAPAttributeType * at, struct berval *bv ));
+
LDAP_F( char * )
ldap_syntax2str LDAP_P((
LDAPSyntax * syn ));
+LDAP_F( struct berval * )
+ldap_syntax2bv LDAP_P((
+ LDAPSyntax * syn, struct berval *bv ));
+
LDAP_F( char * )
ldap_matchingrule2str LDAP_P((
LDAPMatchingRule * mr ));
+LDAP_F( struct berval * )
+ldap_matchingrule2bv LDAP_P((
+ LDAPMatchingRule * mr, struct berval *bv ));
+
LDAP_F( char * )
ldap_matchingruleuse2str LDAP_P((
LDAPMatchingRuleUse * mru ));
+LDAP_F( struct berval * )
+ldap_matchingruleuse2bv LDAP_P((
+ LDAPMatchingRuleUse * mru, struct berval *bv ));
+
LDAP_F( char * )
ldap_scherr2str LDAP_P((
int code )) LDAP_GCCATTR((const));
return(ss->val);
}
+static char *
+safe_strdup(safe_string * ss)
+{
+ char *ret = LDAP_MALLOC(ss->pos+1);
+ if (!ret)
+ return NULL;
+ AC_MEMCPY(ret, ss->val, ss->pos);
+ ret[ss->pos] = '\0';
+ return ret;
+}
+
static int
append_to_safe_string(safe_string * ss, char * s)
{
char *
ldap_syntax2str( LDAPSyntax * syn )
+{
+ struct berval bv;
+ if (ldap_syntax2bv( syn, &bv ))
+ return(bv.bv_val);
+ else
+ return NULL;
+}
+
+struct berval *
+ldap_syntax2bv( LDAPSyntax * syn, struct berval *bv )
{
safe_string * ss;
- char * retstring;
ss = new_safe_string(256);
if ( !ss )
print_literal(ss,/*(*/ ")");
- retstring = LDAP_STRDUP(safe_string_val(ss));
+ bv->bv_val = safe_strdup(ss);
+ bv->bv_len = ss->pos;
safe_string_free(ss);
- return(retstring);
+ return(bv);
}
char *
ldap_matchingrule2str( LDAPMatchingRule * mr )
+{
+ struct berval bv;
+ if (ldap_matchingrule2bv( mr, &bv ))
+ return(bv.bv_val);
+ else
+ return NULL;
+}
+
+struct berval *
+ldap_matchingrule2bv( LDAPMatchingRule * mr, struct berval *bv )
{
safe_string * ss;
- char * retstring;
ss = new_safe_string(256);
if ( !ss )
print_literal(ss,/*(*/")");
- retstring = LDAP_STRDUP(safe_string_val(ss));
+ bv->bv_val = safe_strdup(ss);
+ bv->bv_len = ss->pos;
safe_string_free(ss);
- return(retstring);
+ return(bv);
}
char *
ldap_matchingruleuse2str( LDAPMatchingRuleUse * mru )
+{
+ struct berval bv;
+ if (ldap_matchingruleuse2bv( mru, &bv ))
+ return(bv.bv_val);
+ else
+ return NULL;
+}
+
+struct berval *
+ldap_matchingruleuse2bv( LDAPMatchingRuleUse * mru, struct berval *bv )
{
safe_string * ss;
- char * retstring;
ss = new_safe_string(256);
if ( !ss )
print_literal(ss,/*(*/")");
- retstring = LDAP_STRDUP(safe_string_val(ss));
+ bv->bv_val = safe_strdup(ss);
+ bv->bv_len = ss->pos;
safe_string_free(ss);
- return(retstring);
+ return(bv);
}
char *
ldap_objectclass2str( LDAPObjectClass * oc )
+{
+ struct berval bv;
+ if (ldap_objectclass2bv( oc, &bv ))
+ return(bv.bv_val);
+ else
+ return NULL;
+}
+
+struct berval *
+ldap_objectclass2bv( LDAPObjectClass * oc, struct berval *bv )
{
safe_string * ss;
- char * retstring;
ss = new_safe_string(256);
if ( !ss )
print_literal(ss, /*(*/")");
- retstring = LDAP_STRDUP(safe_string_val(ss));
+ bv->bv_val = safe_strdup(ss);
+ bv->bv_len = ss->pos;
safe_string_free(ss);
- return(retstring);
+ return(bv);
}
char *
-ldap_attributetype2str( LDAPAttributeType * at )
+ldap_attributetype2str( LDAPAttributeType * at )
+{
+ struct berval bv;
+ if (ldap_attributetype2bv( at, &bv ))
+ return(bv.bv_val);
+ else
+ return NULL;
+}
+
+struct berval *
+ldap_attributetype2bv( LDAPAttributeType * at, struct berval *bv )
{
safe_string * ss;
- char * retstring;
ss = new_safe_string(256);
if ( !ss )
print_literal(ss,/*(*/")");
- retstring = LDAP_STRDUP(safe_string_val(ss));
+ bv->bv_val = safe_strdup(ss);
+ bv->bv_len = ss->pos;
safe_string_free(ss);
- return(retstring);
+ return(bv);
}
/*
vals[1] = NULL;
for ( at = attr_list; at; at = at->sat_next ) {
- val.bv_val = ldap_attributetype2str( &at->sat_atype );
- if ( val.bv_val == NULL ) {
+ if ( ldap_attributetype2bv( &at->sat_atype, &val ) == NULL ) {
return -1;
}
- val.bv_len = strlen( val.bv_val );
#if 0
Debug( LDAP_DEBUG_TRACE, "Merging at [%ld] %s\n",
(long) val.bv_len, val.bv_val, 0 );
continue;
}
- val.bv_val = ldap_matchingrule2str( &mr->smr_mrule );
-
- if ( val.bv_val == NULL ) {
+ if ( ldap_matchingrule2bv( &mr->smr_mrule, &val ) == NULL ) {
return -1;
}
-
- val.bv_len = strlen( val.bv_val );
#if 0
Debug( LDAP_DEBUG_TRACE, "Merging mr [%ld] %s\n",
(long) val.bv_len, val.bv_val, 0 );
vals[1] = NULL;
for ( oc = oc_list; oc; oc = oc->soc_next ) {
- val.bv_val = ldap_objectclass2str( &oc->soc_oclass );
- if ( val.bv_val == NULL ) {
+ if ( ldap_objectclass2bv( &oc->soc_oclass, &val ) == NULL ) {
return -1;
}
- val.bv_len = strlen( val.bv_val );
#if 0
Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s\n",
(long) val.bv_len, val.bv_val, 0 );
continue;
}
- val.bv_val = ldap_syntax2str( &syn->ssyn_syn );
- if ( val.bv_val == NULL ) {
+ if ( ldap_syntax2bv( &syn->ssyn_syn, &val ) == NULL ) {
return -1;
}
- val.bv_len = strlen( val.bv_val );
#if 0
#ifdef NEW_LOGGING
LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY,