Add ber_bvstr and ber_bvstrdup string to berval allocators.

This commit is contained in:
Kurt Zeilenga 1999-12-17 05:37:33 +00:00
parent ab7c490960
commit 37d28e7d0d
3 changed files with 69 additions and 1 deletions

View File

@ -470,6 +470,14 @@ LIBLBER_F( struct berval * )
ber_bvdup LDAP_P((
LDAP_CONST struct berval *bv ));
LIBLBER_F( struct berval * )
ber_bvstr LDAP_P((
LDAP_CONST char * ));
LIBLBER_F( struct berval * )
ber_bvstrdup LDAP_P((
LDAP_CONST char * ));
LIBLBER_F( char * )
ber_strdup LDAP_P((
LDAP_CONST char * ));

View File

@ -118,7 +118,7 @@
# define LIBLUTIL_F(type) extern type
#endif
/* SLAPD (as a module exporting symbols */
/* SLAPD (as a module exporting symbols) */
#if defined(LIBSLAPD_DECL) && defined(_WIN32)
# define LIBSLAPD_F(type) extern __declspec(LIBSLAPD_DECL) type
#else

View File

@ -292,6 +292,66 @@ ber_bvdup(
return( new );
}
struct berval *
ber_bvstr(
LDAP_CONST char *s )
{
struct berval *new;
ber_int_options.lbo_valid = LBER_INITIALIZED;
if( s == NULL ) {
ber_errno = LBER_ERROR_PARAM;
return NULL;
}
if(( new = LBER_MALLOC( sizeof(struct berval) )) == NULL ) {
ber_errno = LBER_ERROR_MEMORY;
return NULL;
}
if ( *s == '\0' ) {
new->bv_val = NULL;
new->bv_len = 0;
return new;
}
new->bv_val = (char *) s;
new->bv_len = strlen( s );
return( new );
}
struct berval *
ber_bvstrdup(
LDAP_CONST char *s )
{
struct berval *new;
char *p;
ber_int_options.lbo_valid = LBER_INITIALIZED;
if( s == NULL ) {
ber_errno = LBER_ERROR_PARAM;
return NULL;
}
p = LBER_STRDUP( s );
if( p == NULL ) {
ber_errno = LBER_ERROR_MEMORY;
return NULL;
}
new = ber_bvstr( p );
if( new == NULL || *p == '\0' ) {
LBER_FREE( p );
}
return( new );
}
char *
ber_strdup( LDAP_CONST char *s )
{