1 /* $OpenLDAP: pkg/ldap/libraries/libldap/string.c,v 1.23.2.3 2008/02/11 23:26:41 kurt Exp $ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2008 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in the file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
17 * Locale-specific 1-byte character versions
18 * See utf-8.c for UTF-8 versions
23 #include <ac/stdlib.h>
24 #include <ac/string.h>
31 #if defined ( HAVE_STRSPN )
32 #define int_strspn strspn
34 static int int_strspn( const char *str
, const char *delim
)
39 for( pos
=0; (*str
) ; pos
++,str
++) {
41 for( p
=delim
; (*p
) ; p
++ ) {
56 #if defined( HAVE_STRPBRK )
57 #define int_strpbrk strpbrk
59 static char *(int_strpbrk
)( const char *str
, const char *accept
)
63 for( ; (*str
) ; str
++ ) {
64 for( p
=accept
; (*p
) ; p
++) {
75 char *(ldap_pvt_strtok
)( char *str
, const char *delim
, char **pos
)
91 /* skip any initial delimiters */
92 str
+= int_strspn( str
, delim
);
97 p
= int_strpbrk( str
, delim
);
110 ldap_pvt_str2upper( char *str
)
116 for ( s
= str
; *s
; s
++ ) {
117 *s
= TOUPPER( (unsigned char) *s
);
125 ldap_pvt_str2upperbv( char *str
, struct berval
*bv
)
129 assert( bv
!= NULL
);
133 for ( s
= str
; *s
; s
++ ) {
134 *s
= TOUPPER( (unsigned char) *s
);
139 bv
->bv_len
= (ber_len_t
)(s
- str
);
145 ldap_pvt_str2lower( char *str
)
151 for ( s
= str
; *s
; s
++ ) {
152 *s
= TOLOWER( (unsigned char) *s
);
160 ldap_pvt_str2lowerbv( char *str
, struct berval
*bv
)
164 assert( bv
!= NULL
);
168 for ( s
= str
; *s
; s
++ ) {
169 *s
= TOLOWER( (unsigned char) *s
);
174 bv
->bv_len
= (ber_len_t
)(s
- str
);