Commit 5a01db28 authored by Howard Chu's avatar Howard Chu
Browse files

Moved slap_strcopy, slap_strncopy to lutil_strcopy, lutil_strncopy

parent f969443f
......@@ -1106,24 +1106,24 @@ accessmask2str( slap_mask_t mask, char *buf )
if ( ACL_IS_LEVEL( mask ) ) {
if ( ACL_LVL_IS_NONE(mask) ) {
ptr = slap_strcopy( ptr, "none" );
ptr = lutil_strcopy( ptr, "none" );
} else if ( ACL_LVL_IS_AUTH(mask) ) {
ptr = slap_strcopy( ptr, "auth" );
ptr = lutil_strcopy( ptr, "auth" );
} else if ( ACL_LVL_IS_COMPARE(mask) ) {
ptr = slap_strcopy( ptr, "compare" );
ptr = lutil_strcopy( ptr, "compare" );
} else if ( ACL_LVL_IS_SEARCH(mask) ) {
ptr = slap_strcopy( ptr, "search" );
ptr = lutil_strcopy( ptr, "search" );
} else if ( ACL_LVL_IS_READ(mask) ) {
ptr = slap_strcopy( ptr, "read" );
ptr = lutil_strcopy( ptr, "read" );
} else if ( ACL_LVL_IS_WRITE(mask) ) {
ptr = slap_strcopy( ptr, "write" );
ptr = lutil_strcopy( ptr, "write" );
} else {
ptr = slap_strcopy( ptr, "unknown" );
ptr = lutil_strcopy( ptr, "unknown" );
}
*ptr++ = '(';
......
......@@ -793,9 +793,9 @@ int bdb_fix_dn(
ptr = e->e_name.bv_val;
nptr = e->e_nname.bv_val;
for (n = o; n && n->i_parent; n=n->i_parent) {
ptr = slap_strcopy(ptr, n->i_rdn->rdn.bv_val);
ptr = lutil_strcopy(ptr, n->i_rdn->rdn.bv_val);
*ptr++ = ',';
nptr = slap_strcopy(nptr, n->i_rdn->nrdn.bv_val);
nptr = lutil_strcopy(nptr, n->i_rdn->nrdn.bv_val);
*nptr++ = ',';
}
ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr);
......
......@@ -325,18 +325,18 @@ suffix_massage_regexize( const char *s )
res = ch_calloc( sizeof( char ), strlen( s ) + 4 + 4*i + 1 );
ptr = slap_strcopy( res, "(.*)" );
ptr = lutil_strcopy( res, "(.*)" );
for ( i = 0, p = s;
( r = strchr( p, ',' ) ) != NULL;
p = r + 1 , i++ ) {
ptr = slap_strncopy( ptr, p, r - p + 1 );
ptr = slap_strcopy( ptr, "[ ]?" );
ptr = lutil_strncopy( ptr, p, r - p + 1 );
ptr = lutil_strcopy( ptr, "[ ]?" );
if ( r[ 1 ] == ' ' ) {
r++;
}
}
slap_strcopy( ptr, p );
lutil_strcopy( ptr, p );
return res;
}
......
......@@ -176,12 +176,12 @@ ldap_back_group(
goto cleanup;
}
ptr = slap_strcopy(filter, "(&(objectclass=");
ptr = slap_strcopy(ptr, group_oc_name.bv_val);
ptr = slap_strcopy(ptr, ")(");
ptr = slap_strcopy(ptr, group_at_name.bv_val);
ptr = slap_strcopy(ptr, "=");
ptr = slap_strcopy(ptr, mop_ndn.bv_val);
ptr = lutil_strcopy(filter, "(&(objectclass=");
ptr = lutil_strcopy(ptr, group_oc_name.bv_val);
ptr = lutil_strcopy(ptr, ")(");
ptr = lutil_strcopy(ptr, group_at_name.bv_val);
ptr = lutil_strcopy(ptr, "=");
ptr = lutil_strcopy(ptr, mop_ndn.bv_val);
strcpy(ptr, "))");
gattr[0] = "objectclass";
......
......@@ -250,12 +250,12 @@ meta_back_group(
goto cleanup;
}
ptr = slap_strcopy( filter, "(&(objectclass=" );
ptr = slap_strcopy( ptr , group_oc_name.bv_val );
ptr = slap_strcopy( ptr , ")(" );
ptr = slap_strcopy( ptr , group_at_name.bv_val );
ptr = slap_strcopy( ptr , "=" );
ptr = slap_strcopy( ptr , mop_ndn.bv_val );
ptr = lutil_strcopy( filter, "(&(objectclass=" );
ptr = lutil_strcopy( ptr , group_oc_name.bv_val );
ptr = lutil_strcopy( ptr , ")(" );
ptr = lutil_strcopy( ptr , group_at_name.bv_val );
ptr = lutil_strcopy( ptr , "=" );
ptr = lutil_strcopy( ptr , mop_ndn.bv_val );
strcpy( ptr , "))" );
gattr[ 0 ] = "objectclass";
......
......@@ -48,7 +48,7 @@ perl_back_compare(
avastr = ch_malloc( ava->aa_desc->ad_cname.bv_len + 1 +
ava->aa_value.bv_len + 1 );
slap_strcopy( slap_strcopy( slap_strcopy( avastr,
lutil_strcopy( lutil_strcopy( lutil_strcopy( avastr,
ava->aa_desc->ad_cname.bv_val ), "=" ),
ava->aa_value.bv_val );
......
......@@ -211,38 +211,3 @@ charray_strcasecmp( const char **a1, const char **a2 )
return 0;
}
/* strcopy is like strcpy except it returns a pointer to the trailing NUL of
* the result string. This allows fast construction of catenated strings
* without the overhead of strlen/strcat.
*/
char *
slap_strcopy(
char *a,
const char *b
)
{
if (!a || !b)
return a;
while ((*a++ = *b++)) ;
return a-1;
}
/* strncopy is like strcpy except it returns a pointer to the trailing NUL of
* the result string. This allows fast construction of catenated strings
* without the overhead of strlen/strcat.
*/
char *
slap_strncopy(
char *a,
const char *b,
size_t n
)
{
if (!a || !b || n == 0)
return a;
while ((*a++ = *b++) && n-- > 0) ;
return a-1;
}
......@@ -107,7 +107,7 @@ void slapd_slp_init( const char* urls ) {
slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i],
strlen( host ) +
sizeof( LDAP_SRVTYPE_PREFIX ) );
strcpy( slap_strcopy(slapd_srvurls[i],
strcpy( lutil_strcopy(slapd_srvurls[i],
LDAP_SRVTYPE_PREFIX ), host );
ch_free( host );
......@@ -119,7 +119,7 @@ void slapd_slp_init( const char* urls ) {
slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i],
strlen( host ) +
sizeof( LDAPS_SRVTYPE_PREFIX ) );
strcpy( slap_strcopy(slapd_srvurls[i],
strcpy( lutil_strcopy(slapd_srvurls[i],
LDAPS_SRVTYPE_PREFIX ), host );
ch_free( host );
......
......@@ -799,7 +799,7 @@ build_new_dn( struct berval * new_dn,
new_dn->bv_len = parent_dn->bv_len + newrdn->bv_len + 1;
new_dn->bv_val = (char *) ch_malloc( new_dn->bv_len + 1 );
ptr = slap_strcopy( new_dn->bv_val, newrdn->bv_val );
ptr = lutil_strcopy( new_dn->bv_val, newrdn->bv_val );
*ptr++ = ',';
strcpy( ptr, parent_dn->bv_val );
}
......
......@@ -27,7 +27,7 @@ lock_fopen( const char *fname, const char *type, FILE **lfp )
char buf[MAXPATHLEN];
/* open the lock file */
strcpy(slap_strcopy( buf, fname ), ".lock" );
strcpy(lutil_strcopy( buf, fname ), ".lock" );
if ( (*lfp = fopen( buf, "w" )) == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR,
......
......@@ -267,11 +267,6 @@ LDAP_SLAPD_F (char **) str2charray LDAP_P(( const char *str, const char *brkstr
LDAP_SLAPD_F (int) charray_strcmp LDAP_P(( const char **a1, const char **a2 ));
LDAP_SLAPD_F (int) charray_strcasecmp LDAP_P(( const char **a1, const char **a2 ));
LDAP_SLAPD_F (char *) slap_strcopy LDAP_P((
char *dst, const char *src ));
LDAP_SLAPD_F (char *) slap_strncopy LDAP_P((
char *dst, const char *src, size_t n ));
/*
* controls.c
*/
......
......@@ -400,24 +400,24 @@ int slap_sasl_getdn( Connection *conn, char *id, int len,
/* Build the new dn */
c1 = dn->bv_val;
dn->bv_val = ch_malloc( len+1 );
p = slap_strcopy( dn->bv_val, "uid=" );
p = slap_strncopy( p, c1, dn->bv_len );
p = lutil_strcopy( dn->bv_val, "uid=" );
p = lutil_strncopy( p, c1, dn->bv_len );
if( realm ) {
int rlen = dn->bv_len - ( realm - c1 );
p = slap_strcopy( p, ",cn=" );
p = slap_strncopy( p, realm, rlen );
p = lutil_strcopy( p, ",cn=" );
p = lutil_strncopy( p, realm, rlen );
realm[-1] = '@';
} else if( user_realm && *user_realm ) {
p = slap_strcopy( p, ",cn=" );
p = slap_strcopy( p, user_realm );
p = lutil_strcopy( p, ",cn=" );
p = lutil_strcopy( p, user_realm );
}
if( conn->c_sasl_bind_mech.bv_len ) {
p = slap_strcopy( p, ",cn=" );
p = slap_strcopy( p, conn->c_sasl_bind_mech.bv_val );
p = lutil_strcopy( p, ",cn=" );
p = lutil_strcopy( p, conn->c_sasl_bind_mech.bv_val );
}
p = slap_strcopy( p, ",cn=auth" );
p = lutil_strcopy( p, ",cn=auth" );
dn->bv_len = p - dn->bv_val;
#ifdef NEW_LOGGING
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment