From 5a01db28e301fcd691f76ecf904e96ecf9a448b8 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sat, 27 Jul 2002 00:24:02 +0000 Subject: [PATCH] Moved slap_strcopy, slap_strncopy to lutil_strcopy, lutil_strncopy --- servers/slapd/aclparse.c | 14 ++++++------- servers/slapd/back-bdb/dn2id.c | 4 ++-- servers/slapd/back-ldap/config.c | 8 +++---- servers/slapd/back-ldap/group.c | 12 +++++------ servers/slapd/back-meta/group.c | 12 +++++------ servers/slapd/back-perl/compare.c | 2 +- servers/slapd/charray.c | 35 ------------------------------- servers/slapd/daemon.c | 4 ++-- servers/slapd/dn.c | 2 +- servers/slapd/lock.c | 2 +- servers/slapd/proto-slap.h | 5 ----- servers/slapd/sasl.c | 18 ++++++++-------- 12 files changed, 39 insertions(+), 79 deletions(-) diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 4af093f1a0..51f0a0c1c3 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -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++ = '('; diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 9f4c5a5c0f..4e8d02cd60 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -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); diff --git a/servers/slapd/back-ldap/config.c b/servers/slapd/back-ldap/config.c index a8e82ad0ea..f0ea612e81 100644 --- a/servers/slapd/back-ldap/config.c +++ b/servers/slapd/back-ldap/config.c @@ -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; } diff --git a/servers/slapd/back-ldap/group.c b/servers/slapd/back-ldap/group.c index 374ffc2959..16a2c5046e 100644 --- a/servers/slapd/back-ldap/group.c +++ b/servers/slapd/back-ldap/group.c @@ -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"; diff --git a/servers/slapd/back-meta/group.c b/servers/slapd/back-meta/group.c index 14d624aa30..67886898a3 100644 --- a/servers/slapd/back-meta/group.c +++ b/servers/slapd/back-meta/group.c @@ -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"; diff --git a/servers/slapd/back-perl/compare.c b/servers/slapd/back-perl/compare.c index cf167b3b31..41e2299103 100644 --- a/servers/slapd/back-perl/compare.c +++ b/servers/slapd/back-perl/compare.c @@ -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 ); diff --git a/servers/slapd/charray.c b/servers/slapd/charray.c index e8c3dbc048..46bff0714a 100644 --- a/servers/slapd/charray.c +++ b/servers/slapd/charray.c @@ -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; -} diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 4c297f52d1..c732e1afa6 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -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 ); diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 346817765b..23aa4e7839 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -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 ); } diff --git a/servers/slapd/lock.c b/servers/slapd/lock.c index 29d89ad270..13fe405b14 100644 --- a/servers/slapd/lock.c +++ b/servers/slapd/lock.c @@ -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, diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 3e75823e0d..6503d5322e 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -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 */ diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index 59c6047614..b9b23458d2 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.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 -- 2.39.5