X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fstring.c;h=4f860ada785e68cfee3c875b314a42bd7ccffc13;hb=de01a6e3d791d3458549d2ceeccf4d7e0477ff78;hp=a0877bb68342b3d290a63d7ff2822dbd0552562d;hpb=941087a09dcec4d5d68c3fca0a77dca1a203436b;p=openldap
diff --git a/libraries/libldap/string.c b/libraries/libldap/string.c
index a0877bb683..4f860ada78 100644
--- a/libraries/libldap/string.c
+++ b/libraries/libldap/string.c
@@ -1,13 +1,29 @@
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 1998-2007 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
+ * .
+ */
+
/*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ * Locale-specific 1-byte character versions
+ * See utf-8.c for UTF-8 versions
*/
#include "portable.h"
-#include
+#include
#include
#include
+#include
#include "ldap-int.h"
@@ -58,9 +74,6 @@ static char *(int_strpbrk)( const char *str, const char *accept )
char *(ldap_pvt_strtok)( char *str, const char *delim, char **pos )
{
-#if defined( HAVE_STRTOK_R ) || defined( HAVE_REENTRANT_FUNCTIONS )
- return strtok_r(str, delim, pos);
-#else
char *p;
if (pos==NULL) {
@@ -91,19 +104,74 @@ char *(ldap_pvt_strtok)( char *str, const char *delim, char **pos )
}
return str;
-#endif
}
char *
-(ldap_pvt_strdup)( const char *s )
+ldap_pvt_str2upper( char *str )
+{
+ char *s;
+
+ /* to upper */
+ 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 *p;
- int len = strlen( s ) + 1;
+ char *s;
- if ( (p = (char *) malloc( len )) == NULL ) {
- return( (char *)0 );
+ /* to lower */
+ if ( str ) {
+ for ( s = str; *s; s++ ) {
+ *s = TOLOWER( (unsigned char) *s );
+ }
}
- memcpy( p, s, len );
- return( p );
+ 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 );
}