]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/string.c
Merge remote-tracking branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4
[openldap] / libraries / libldap / string.c
index df8069ccaabe80c4e9da084decf7e1db1f711032..0d712731e3374239bd25d57790993764406b60c2 100644 (file)
@@ -1,7 +1,16 @@
 /* $OpenLDAP$ */
-/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2013 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
  */
 
 /*
@@ -103,22 +112,66 @@ ldap_pvt_str2upper( char *str )
        char    *s;
 
        /* to upper */
-       for ( s = str; *s; s++ ) {
-               *s = TOUPPER( (unsigned char) *s );
+       if ( str ) {
+               for ( s = str; *s; s++ ) {
+                       *s = TOUPPER( (unsigned char) *s );
+               }
        }
 
        return( str );
 }
 
+struct berval *
+ldap_pvt_str2upperbv( char *str, struct berval *bv )
+{
+       char    *s = NULL;
+
+       assert( bv != NULL );
+
+       /* to upper */
+       if ( str ) {
+               for ( s = str; *s; s++ ) {
+                       *s = TOUPPER( (unsigned char) *s );
+               }
+       }
+
+       bv->bv_val = str;
+       bv->bv_len = (ber_len_t)(s - str);
+       
+       return( bv );
+}
+
 char *
 ldap_pvt_str2lower( char *str )
 {
        char    *s;
 
        /* to lower */
-       for ( s = str; *s; s++ ) {
-               *s = TOLOWER( (unsigned char) *s );
+       if ( str ) {
+               for ( s = str; *s; s++ ) {
+                       *s = TOLOWER( (unsigned char) *s );
+               }
        }
 
        return( str );
 }
+
+struct berval *
+ldap_pvt_str2lowerbv( char *str, struct berval *bv )
+{
+       char    *s = NULL;
+
+       assert( bv != NULL );
+
+       /* to lower */
+       if ( str ) {
+               for ( s = str; *s; s++ ) {
+                       *s = TOLOWER( (unsigned char) *s );
+               }
+       }
+
+       bv->bv_val = str;
+       bv->bv_len = (ber_len_t)(s - str);
+
+       return( bv );
+}