Begin Project Dependency
Project_Dep_Name ucgendat
End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name dntest
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name ftest
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "dntest"=..\libraries\libldap\dntest.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name liblber
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name libldap
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name liblutil
+ End Project Dependency
}}}
###############################################################################
###############################################################################
+Project: "ftest"=..\libraries\libldap\ftest.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name liblber
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name libldap
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name liblutil
+ End Project Dependency
+}}}
+
+###############################################################################
+
Project: "ldapdelete"=..\clients\tools\ldapdelete.dsp - Package Owner=<4>
Package=<5>
#ifndef _LDAP_PVT_H
#define _LDAP_PVT_H 1
-#include <ldap_cdefs.h>
#include <lber.h> /* get ber_slen_t */
LDAP_BEGIN_DECL
* these macros assume 'x' is an ASCII x
* and assume the "C" locale
*/
+#define LDAP_ASCII(c) ((c) < 0x80)
#define LDAP_SPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\n')
#define LDAP_DIGIT(c) ((c) >= '0' && (c) <= '9')
#define LDAP_LOWER(c) ((c) >= 'a' && (c) <= 'z')
#define LDAP_ALPHA(c) (LDAP_LOWER(c) || LDAP_UPPER(c))
#define LDAP_ALNUM(c) (LDAP_ALPHA(c) || LDAP_DIGIT(c))
+#define LDAP_LDH(c) (LDAP_ALNUM(c) || (c) == '-')
+
+#define LDAP_HEXLOWER(c) ((c) >= 'a' && (c) <= 'f')
+#define LDAP_HEXUPPER(c) ((c) >= 'A' && (c) <= 'F')
+#define LDAP_HEX(c) (LDAP_DIGIT(c) || \
+ LDAP_HEXLOWER(c) || LDAP_HEXUPPER(c))
#ifdef HAVE_CYRUS_SASL
/* cyrus.c */
#ifndef _LDAP_PVT_UC_H
#define _LDAP_PVT_UC_H 1
-#include <ldap_cdefs.h>
#include <lber.h> /* get ber_slen_t */
#ifdef _MSC_VER
LDAP_V (const char) ldap_utf8_lentab[128];
#define LDAP_UTF8_ISASCII(p) ( *(unsigned char *)(p) ^ 0x80 )
-#define LDAP_UTF8_ISSPACE(p) ( *(p) == ' ' || (*(p) >= '\t' && *(p) <= '\r') )
#define LDAP_UTF8_CHARLEN(p) ( LDAP_UTF8_ISASCII(p) \
? 1 : ldap_utf8_lentab[*(unsigned char *)(p) ^ 0x80] )
#define LDAP_UTF8_OFFSET(p) ( LDAP_UTF8_ISASCII(p) \
? 1 : ldap_utf8_offset((p)) )
-#define LDAP_UTF8_COPY(d,s) ( LDAP_UTF8_ISASCII(s) \
+#define LDAP_UTF8_COPY(d,s) ( LDAP_UTF8_ISASCII(s) \
? (*(d) = *(s), 1) : ldap_utf8_copy((d),(s)) )
#define LDAP_UTF8_NEXT(p) ( LDAP_UTF8_ISASCII(p) \
ldap_unicode_t *,
ber_len_t );
-#define UTF8_CASEFOLD 1
-#define UTF8_NOCASEFOLD 0
+#define LDAP_UTF8_CASEFOLD 0x1U
+#define LDAP_UTF8_NOCASEFOLD 0x0U
LDAP_LUNICODE_F(char *) UTF8normalize(
struct berval *,
- char );
+ unsigned );
LDAP_LUNICODE_F(int) UTF8normcmp(
const char *,
const char *,
- char );
+ unsigned );
LDAP_END_DECL
}
}
-breakout:
va_end( ap );
-
if ( rc == LBER_DEFAULT ) {
/*
* Error. Reclaim malloced memory that was given to the caller.
# End Source File
# Begin Source File
-SOURCE="..\..\include\queue-compat.h"
-# End Source File
-# Begin Source File
-
SOURCE=.\sockbuf.c
# End Source File
# End Target
* attr and value) are supplied. The msgid of the response is returned.
*
* Example:
- * struct berval bvalue = { "secret", strlen("secret") };
+ * struct berval bvalue = { "secret", sizeof("secret")-1 };
* rc = ldap_compare( ld, "c=us@cn=bob",
* "userPassword", &bvalue,
* sctrl, cctrl, &msgid )
len = sec_buf_in->buf_ptr - sec_buf_in->buf_end;
if ( len > 0 )
- memmove( sec_buf_in->buf_base, sec_buf_in->buf_base +
+ AC_MEMCPY( sec_buf_in->buf_base, sec_buf_in->buf_base +
sec_buf_in->buf_end, len );
if ( len >= 4 ) {
*/
#define LDAP_DN_ASCII_SPACE(c) \
( (c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r' )
-#define LDAP_DN_ASCII_LOWER(c) ( (c) >= 'a' && (c) <= 'z' )
-#define LDAP_DN_ASCII_UPPER(c) ( (c) >= 'A' && (c) <= 'Z' )
-#define LDAP_DN_ASCII_ALPHA(c) \
- ( LDAP_DN_ASCII_LOWER(c) || LDAP_DN_ASCII_UPPER(c) )
-#define LDAP_DN_ASCII_DIGIT(c) ( (c) >= '0' && (c) <= '9' )
-#define LDAP_DN_ASCII_LCASE_HEXALPHA(c) ( (c) >= 'a' && (c) <= 'f' )
-#define LDAP_DN_ASCII_UCASE_HEXALPHA(c) ( (c) >= 'A' && (c) <= 'F' )
-#define LDAP_DN_ASCII_HEXDIGIT(c) \
- ( LDAP_DN_ASCII_DIGIT(c) \
- || LDAP_DN_ASCII_LCASE_HEXALPHA(c) \
- || LDAP_DN_ASCII_UCASE_HEXALPHA(c) )
-#define LDAP_DN_ASCII_ALNUM(c) \
- ( LDAP_DN_ASCII_ALPHA(c) || LDAP_DN_ASCII_DIGIT(c) )
+#define LDAP_DN_ASCII_LOWER(c) LDAP_LOWER(c)
+#define LDAP_DN_ASCII_UPPER(c) LDAP_UPPER(c)
+#define LDAP_DN_ASCII_ALPHA(c) LDAP_ALPHA(c)
+
+#define LDAP_DN_ASCII_DIGIT(c) LDAP_DIGIT(c)
+#define LDAP_DN_ASCII_LCASE_HEXALPHA(c) LDAP_HEXLOWER(c)
+#define LDAP_DN_ASCII_UCASE_HEXALPHA(c) LDAP_HEXUPPER(c)
+#define LDAP_DN_ASCII_HEXDIGIT(c) LDAP_HEX(c)
+#define LDAP_DN_ASCII_ALNUM(c) LDAP_ALNUM(c)
#define LDAP_DN_ASCII_PRINTABLE(c) ( (c) >= ' ' && (c) <= '~' )
/* attribute type */
-#define LDAP_DN_OID_LEADCHAR(c) ( LDAP_DN_ASCII_DIGIT(c) )
-#define LDAP_DN_DESC_LEADCHAR(c) ( LDAP_DN_ASCII_ALPHA(c) )
-#define LDAP_DN_DESC_CHAR(c) ( LDAP_DN_ASCII_ALNUM(c) || (c) == '-' )
+#define LDAP_DN_OID_LEADCHAR(c) LDAP_DIGIT(c)
+#define LDAP_DN_DESC_LEADCHAR(c) LDAP_ALPHA(c)
+#define LDAP_DN_DESC_CHAR(c) LDAP_LDH(c)
#define LDAP_DN_LANG_SEP(c) ( (c) == ';' )
#define LDAP_DN_ATTRDESC_CHAR(c) \
( LDAP_DN_DESC_CHAR(c) || LDAP_DN_LANG_SEP(c) )
}
for ( ; p[ 0 ]; p++ ) {
- LDAPDN *dn;
int err;
err = ldap_str2rdn( p, &newRDN, &p, flags );
}
- Debug( LDAP_DEBUG_TRACE, "<= ldap_dn2bv(%s,%u)=%d\n", bv->bv_val, flags, rc );
+ Debug( LDAP_DEBUG_TRACE, "<= ldap_dn2bv(%s,%u)=%d\n",
+ bv->bv_val, flags, rc );
return_results:;
return( rc );
}
# End Source File
# Begin Source File
+SOURCE=.\filter.c
+# End Source File
+# Begin Source File
+
SOURCE=.\free.c
# End Source File
# Begin Source File
#include "ldap-int.h"
-static int ldap_is_attr_oid LDAP_P((
- const char *attr ));
-
-static int ldap_is_attr_desc LDAP_P((
- const char *attr ));
-
-static int hex2value LDAP_P((
- int c ));
-
-static char *find_right_paren LDAP_P((
- char *s ));
-
-static char *put_complex_filter LDAP_P((
- BerElement *ber,
- char *str,
- ber_tag_t tag,
- int not ));
-
-int ldap_int_put_filter LDAP_P((
- BerElement *ber,
- char *str ));
-
-#define put_filter(b,s) ldap_int_put_filter((b),(s))
-
-static int put_simple_filter LDAP_P((
- BerElement *ber,
- char *str ));
-
-static int put_substring_filter LDAP_P((
- BerElement *ber,
- char *type,
- char *str ));
-
-static int put_filter_list LDAP_P((
- BerElement *ber,
- char *str,
- ber_tag_t tag ));
/*
* ldap_search_ext - initiate an ldap search operation.
} else {
filter = LDAP_STRDUP( "(objectclass=*)" );
}
- err = put_filter( ber, filter );
+ err = ldap_int_put_filter( ber, filter );
LDAP_FREE( filter );
if ( err == -1 ) {
return( ber );
}
-static int ldap_is_attr_oid ( const char *attr )
-{
- int i, c, digit=0;
-
- for( i = 0; (c = attr[i]) != 0; i++ ) {
- if( c >= '0' && c <= '9' ) {
- digit=1;
-
- } else if ( c != '.' ) {
- /* not digit nor '.' */
- return 0;
-
- } else if ( !digit ) {
- /* '.' but prev not digit */
- return 0;
-
- } else {
- /* '.' */
- digit = 0;
- }
- }
-
- return digit;
-}
-
-static int ldap_is_attr_desc ( const char *attr )
-{
- /* cheap attribute description check */
- int i, c;
-
- for( i = 0; (c = attr[i]) != 0; i++ ) {
- if (( c >= '0' && c <= '9' )
- || ( c >= 'A' && c <= 'Z' )
- || ( c >= 'a' && c <= 'z' )
- || ( c == '.' || c == '-' )
- || ( c == ';' )) continue;
-
- return 0;
- }
-
- return i > 0;
-}
-
-static char *
-find_right_paren( char *s )
-{
- int balance, escape;
-
- balance = 1;
- escape = 0;
- while ( *s && balance ) {
- if ( escape == 0 ) {
- if ( *s == '(' )
- balance++;
- else if ( *s == ')' )
- balance--;
- }
- if ( *s == '\\' && ! escape )
- escape = 1;
- else
- escape = 0;
- if ( balance )
- s++;
- }
-
- return( *s ? s : NULL );
-}
-
-static int hex2value( int c )
-{
- if( c >= '0' && c <= '9' ) {
- return c - '0';
- }
-
- if( c >= 'A' && c <= 'F' ) {
- return c + (10 - (int) 'A');
- }
-
- if( c >= 'a' && c <= 'f' ) {
- return c + (10 - (int) 'a');
- }
-
- return -1;
-}
-
-char *
-ldap_pvt_find_wildcard( const char *s )
-{
- for( ; *s != '\0' ; s++ ) {
- switch( *s ) {
- case '*': /* found wildcard */
- return (char *) s;
-
- case '\\':
- s++; /* skip over escape */
- if ( *s == '\0' )
- return NULL; /* escape at end of string */
- }
- }
-
- return NULL;
-}
-
-/* unescape filter value */
-/* support both LDAP v2 and v3 escapes */
-/* output can include nul characters! */
-ber_slen_t
-ldap_pvt_filter_value_unescape( char *fval )
-{
- ber_slen_t r, v;
- int v1, v2;
-
- for( r=v=0; fval[v] != '\0'; v++ ) {
- switch( fval[v] ) {
- case '\\':
- /* escape */
- v++;
-
- if ( fval[v] == '\0' ) {
- /* escape at end of string */
- return -1;
-
- }
-
- if (( v1 = hex2value( fval[v] )) >= 0 ) {
- /* LDAPv3 escape */
- if (( v2 = hex2value( fval[v+1] )) < 0 ) {
- /* must be two digit code */
- return -1;
- }
-
- fval[r++] = v1 * 16 + v2;
- v++;
-
- } else {
- /* LDAPv2 escape */
- switch( fval[v] ) {
- case '(':
- case ')':
- case '*':
- case '\\':
- fval[r++] = fval[v];
- break;
- default:
- /* illegal escape */
- return -1;
- }
- }
- break;
-
- default:
- fval[r++] = fval[v];
- }
- }
-
- fval[r] = '\0';
- return r;
-}
-
-static char *
-put_complex_filter( BerElement *ber, char *str, ber_tag_t tag, int not )
-{
- char *next;
-
- /*
- * We have (x(filter)...) with str sitting on
- * the x. We have to find the paren matching
- * the one before the x and put the intervening
- * filters by calling put_filter_list().
- */
-
- /* put explicit tag */
- if ( ber_printf( ber, "t{" /*}*/, tag ) == -1 )
- return( NULL );
-
- str++;
- if ( (next = find_right_paren( str )) == NULL )
- return( NULL );
-
- *next = '\0';
- if ( put_filter_list( ber, str, tag ) == -1 )
- return( NULL );
- *next++ = ')';
-
- /* flush explicit tagged thang */
- if ( ber_printf( ber, /*{*/ "N}" ) == -1 )
- return( NULL );
-
- return( next );
-}
-
-int
-ldap_int_put_filter( BerElement *ber, char *str )
-{
- char *next;
- int parens, balance, escape;
-
- /*
- * A Filter looks like this:
- * Filter ::= CHOICE {
- * and [0] SET OF Filter,
- * or [1] SET OF Filter,
- * not [2] Filter,
- * equalityMatch [3] AttributeValueAssertion,
- * substrings [4] SubstringFilter,
- * greaterOrEqual [5] AttributeValueAssertion,
- * lessOrEqual [6] AttributeValueAssertion,
- * present [7] AttributeType,
- * approxMatch [8] AttributeValueAssertion,
- * extensibleMatch [9] MatchingRuleAssertion -- LDAPv3
- * }
- *
- * SubstringFilter ::= SEQUENCE {
- * type AttributeType,
- * SEQUENCE OF CHOICE {
- * initial [0] IA5String,
- * any [1] IA5String,
- * final [2] IA5String
- * }
- * }
- *
- * MatchingRuleAssertion ::= SEQUENCE { -- LDAPv3
- * matchingRule [1] MatchingRuleId OPTIONAL,
- * type [2] AttributeDescription OPTIONAL,
- * matchValue [3] AssertionValue,
- * dnAttributes [4] BOOLEAN DEFAULT FALSE }
- *
- * Note: tags in a choice are always explicit
- */
-
- Debug( LDAP_DEBUG_TRACE, "put_filter \"%s\"\n", str, 0, 0 );
-
- parens = 0;
- while ( *str ) {
- switch ( *str ) {
- case '(':
- str++;
- parens++;
-
- /* skip spaces */
- while( LDAP_SPACE( *str ) ) str++;
-
- switch ( *str ) {
- case '&':
- Debug( LDAP_DEBUG_TRACE, "put_filter: AND\n",
- 0, 0, 0 );
-
- if ( (str = put_complex_filter( ber, str,
- LDAP_FILTER_AND, 0 )) == NULL )
- return( -1 );
-
- parens--;
- break;
-
- case '|':
- Debug( LDAP_DEBUG_TRACE, "put_filter: OR\n",
- 0, 0, 0 );
-
- if ( (str = put_complex_filter( ber, str,
- LDAP_FILTER_OR, 0 )) == NULL )
- return( -1 );
-
- parens--;
- break;
-
- case '!':
- Debug( LDAP_DEBUG_TRACE, "put_filter: NOT\n",
- 0, 0, 0 );
-
- if ( (str = put_complex_filter( ber, str,
- LDAP_FILTER_NOT, 1 )) == NULL )
- return( -1 );
-
- parens--;
- break;
-
- default:
- Debug( LDAP_DEBUG_TRACE, "put_filter: simple\n",
- 0, 0, 0 );
-
- balance = 1;
- escape = 0;
- next = str;
- while ( *next && balance ) {
- if ( escape == 0 ) {
- if ( *next == '(' )
- balance++;
- else if ( *next == ')' )
- balance--;
- }
- if ( *next == '\\' && ! escape )
- escape = 1;
- else
- escape = 0;
- if ( balance )
- next++;
- }
- if ( balance != 0 )
- return( -1 );
-
- *next = '\0';
- if ( put_simple_filter( ber, str ) == -1 ) {
- return( -1 );
- }
- *next++ = ')';
- str = next;
- parens--;
- break;
- }
- break;
-
- case ')':
- Debug( LDAP_DEBUG_TRACE, "put_filter: end\n", 0, 0,
- 0 );
- if ( ber_printf( ber, /*[*/ "]" ) == -1 )
- return( -1 );
- str++;
- parens--;
- break;
-
- case ' ':
- str++;
- break;
-
- default: /* assume it's a simple type=value filter */
- Debug( LDAP_DEBUG_TRACE, "put_filter: default\n", 0, 0,
- 0 );
- next = strchr( str, '\0' );
- if ( put_simple_filter( ber, str ) == -1 ) {
- return( -1 );
- }
- str = next;
- break;
- }
- }
-
- return( parens ? -1 : 0 );
-}
-
-/*
- * Put a list of filters like this "(filter1)(filter2)..."
- */
-
-static int
-put_filter_list( BerElement *ber, char *str, ber_tag_t tag )
-{
- char *next = NULL;
- char save;
-
- Debug( LDAP_DEBUG_TRACE, "put_filter_list \"%s\"\n", str, 0, 0 );
-
- while ( *str ) {
- while ( *str && LDAP_SPACE( (unsigned char) *str ) ) {
- str++;
- }
- if ( *str == '\0' ) break;
-
- if ( (next = find_right_paren( str + 1 )) == NULL ) {
- return( -1 );
- }
- save = *++next;
-
- /* now we have "(filter)" with str pointing to it */
- *next = '\0';
- if ( put_filter( ber, str ) == -1 ) return -1;
- *next = save;
- str = next;
-
- if( tag == LDAP_FILTER_NOT ) break;
- }
-
- if( tag == LDAP_FILTER_NOT && ( next == NULL || *str )) {
- return -1;
- }
-
- return 0;
-}
-
-static int
-put_simple_filter(
- BerElement *ber,
- char *str )
-{
- char *s;
- char *value;
- ber_tag_t ftype;
- int rc = -1;
-
- Debug( LDAP_DEBUG_TRACE, "put_simple_filter \"%s\"\n", str, 0, 0 );
-
- str = LDAP_STRDUP( str );
- if( str == NULL ) return -1;
-
- if ( (s = strchr( str, '=' )) == NULL ) {
- goto done;
- }
-
- value = s + 1;
- *s-- = '\0';
-
- switch ( *s ) {
- case '<':
- ftype = LDAP_FILTER_LE;
- *s = '\0';
- if(! ldap_is_attr_desc( str ) ) goto done;
- break;
-
- case '>':
- ftype = LDAP_FILTER_GE;
- *s = '\0';
- if(! ldap_is_attr_desc( str ) ) goto done;
- break;
-
- case '~':
- ftype = LDAP_FILTER_APPROX;
- *s = '\0';
- if(! ldap_is_attr_desc( str ) ) goto done;
- break;
-
- case ':':
- /* RFC2254 extensible filters are off the form:
- * type [:dn] [:rule] := value
- * or [:dn]:rule := value
- */
- ftype = LDAP_FILTER_EXT;
- *s = '\0';
-
- {
- char *dn = strchr( str, ':' );
- char *rule = NULL;
-
- if( dn == NULL ) {
- if(! ldap_is_attr_desc( str ) ) goto done;
- } else {
-
- *dn++ = '\0';
- rule = strchr( dn, ':' );
-
- if( rule == NULL ) {
- /* one colon */
- if ( strcmp(dn, "dn") == 0 ) {
- /* must have attribute */
- if( !ldap_is_attr_desc( str ) ) {
- goto done;
- }
-
- rule = "";
-
- } else {
- rule = dn;
- dn = NULL;
- }
-
- } else {
- /* two colons */
- *rule++ = '\0';
-
- if ( strcmp(dn, "dn") != 0 ) {
- /* must have "dn" */
- goto done;
- }
- }
-
- }
-
- if ( *str == '\0' && ( !rule || *rule == '\0' ) ) {
- /* must have either type or rule */
- goto done;
- }
-
- if ( *str != '\0' && !ldap_is_attr_desc( str ) ) {
- goto done;
- }
-
- if ( rule && *rule != '\0' && !ldap_is_attr_oid( rule ) ) {
- goto done;
- }
-
- rc = ber_printf( ber, "t{" /*}*/, ftype );
-
- if( rc != -1 && rule && *rule != '\0' ) {
- rc = ber_printf( ber, "ts", LDAP_FILTER_EXT_OID, rule );
- }
- if( rc != -1 && *str != '\0' ) {
- rc = ber_printf( ber, "ts", LDAP_FILTER_EXT_TYPE, str );
- }
-
- if( rc != -1 ) {
- ber_slen_t len = ldap_pvt_filter_value_unescape( value );
-
- if( len >= 0 ) {
- rc = ber_printf( ber, "totbN}",
- LDAP_FILTER_EXT_VALUE, value, len,
- LDAP_FILTER_EXT_DNATTRS, dn != NULL);
- } else {
- rc = -1;
- }
- }
- }
- goto done;
-
- default:
- if ( ldap_pvt_find_wildcard( value ) == NULL ) {
- ftype = LDAP_FILTER_EQUALITY;
- } else if ( strcmp( value, "*" ) == 0 ) {
- ftype = LDAP_FILTER_PRESENT;
- } else {
- rc = put_substring_filter( ber, str, value );
- goto done;
- }
- break;
- }
-
- if ( ftype == LDAP_FILTER_PRESENT ) {
- rc = ber_printf( ber, "ts", ftype, str );
-
- } else {
- ber_slen_t len = ldap_pvt_filter_value_unescape( value );
-
- if( len >= 0 ) {
- rc = ber_printf( ber, "t{soN}",
- ftype, str, value, len );
- }
- }
-
- if( rc != -1 ) rc = 0;
-
-done:
- LDAP_FREE( str );
- return rc;
-}
-
-static int
-put_substring_filter( BerElement *ber, char *type, char *val )
-{
- char *nextstar, gotstar = 0;
- ber_tag_t ftype = LDAP_FILTER_SUBSTRINGS;
-
- Debug( LDAP_DEBUG_TRACE, "put_substring_filter \"%s=%s\"\n", type,
- val, 0 );
-
- if ( ber_printf( ber, "t{s{", ftype, type ) == -1 )
- return( -1 );
-
- for( ; val != NULL; val=nextstar ) {
- if ( (nextstar = ldap_pvt_find_wildcard( val )) != NULL )
- *nextstar++ = '\0';
-
- if ( gotstar == 0 ) {
- ftype = LDAP_SUBSTRING_INITIAL;
- } else if ( nextstar == NULL ) {
- ftype = LDAP_SUBSTRING_FINAL;
- } else {
- ftype = LDAP_SUBSTRING_ANY;
- }
-
- if ( *val != '\0' ) {
- ber_slen_t len = ldap_pvt_filter_value_unescape( val );
-
- if ( len < 0 ) {
- return -1;
- }
-
- if ( ber_printf( ber, "to", ftype, val, len ) == -1 ) {
- return( -1 );
- }
- }
-
- gotstar = 1;
- }
-
- if ( ber_printf( ber, /* {{ */ "N}N}" ) == -1 )
- return( -1 );
-
- return( 0 );
-}
-
int
ldap_search_st(
LDAP *ld, LDAP_CONST char *base, int scope,
#include "ldap-int.h"
#include "ldap_defaults.h"
-#undef LDAP_IS_ASCII
-#define LDAP_IS_ASCII(uc) ((uc) < 0x80)
-
/*
* Basic UTF-8 routines
*/
return i;
}
+#ifndef UTF8_ALPHA_CTYPE
/*
* UTF-8 ctype routines
* Only deals with characters < 0x80 (ie: US-ASCII)
int ldap_utf8_isascii( const char * p )
{
unsigned c = * (const unsigned char *) p;
- return LDAP_IS_ASCII(c);
+ return LDAP_ASCII(c);
}
int ldap_utf8_isdigit( const char * p )
{
unsigned c = * (const unsigned char *) p;
- if(!LDAP_IS_ASCII(c)) return 0;
+ if(!LDAP_ASCII(c)) return 0;
- return c >= '0' && c <= '9';
+ return LDAP_DIGIT( c );
}
int ldap_utf8_isxdigit( const char * p )
{
unsigned c = * (const unsigned char *) p;
- if(!LDAP_IS_ASCII(c)) return 0;
+ if(!LDAP_ASCII(c)) return 0;
- return ( c >= '0' && c <= '9' )
- || ( c >= 'A' && c <= 'F' )
- || ( c >= 'a' && c <= 'f' );
+ return LDAP_HEX(c);
}
int ldap_utf8_isspace( const char * p )
{
unsigned c = * (const unsigned char *) p;
- if(!LDAP_IS_ASCII(c)) return 0;
+ if(!LDAP_ASCII(c)) return 0;
switch(c) {
case ' ':
return 0;
}
-#ifndef UTF8_ALPHA_CTYPE
/*
* These are not needed by the C SDK and are
* not "good enough" for general use.
{
unsigned c = * (const unsigned char *) p;
- if(!LDAP_IS_ASCII(c)) return 0;
+ if(!LDAP_ASCII(c)) return 0;
- return ( c >= 'A' && c <= 'Z' )
- || ( c >= 'a' && c <= 'z' );
+ return LDAP_ALPHA(c);
}
int ldap_utf8_isalnum( const char * p )
{
unsigned c = * (const unsigned char *) p;
- if(!LDAP_IS_ASCII(c)) return 0;
+ if(!LDAP_ASCII(c)) return 0;
- return ( c >= '0' && c <= '9' )
- || ( c >= 'A' && c <= 'Z' )
- || ( c >= 'a' && c <= 'z' );
+ return LDAP_ALNUM(c);
}
int ldap_utf8_islower( const char * p )
{
unsigned c = * (const unsigned char *) p;
- if(!LDAP_IS_ASCII(c)) return 0;
+ if(!LDAP_ASCII(c)) return 0;
- return ( c >= 'a' && c <= 'z' );
+ return LDAP_LOWER(c);
}
int ldap_utf8_isupper( const char * p )
{
unsigned c = * (const unsigned char *) p;
- if(!LDAP_IS_ASCII(c)) return 0;
+ if(!LDAP_ASCII(c)) return 0;
- return ( c >= 'A' && c <= 'Z' );
+ return LDAP_UPPER(c);
}
#endif
#endif
}
-#define BUFSTART 1024
-#define BUFMAX (32*1024)
+#define BUFSTART (1024-32
+#define BUFMAX (32*1024-32)
static char *safe_realloc( char **buf, int len );
# End Source File
# Begin Source File
+SOURCE=..\libldap\filter.c
+# End Source File
+# Begin Source File
+
SOURCE=..\libldap\free.c
# End Source File
# Begin Source File
# End Source File
# Begin Source File
+SOURCE=..\..\include\ldap_config.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\ldap_defaults.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\include\ldap_features.h
# End Source File
# Begin Source File
+SOURCE=..\..\include\ldap_int_thread.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\include\ldap_log.h
# End Source File
# Begin Source File
# End Source File
# Begin Source File
+SOURCE=..\..\include\ldap_pvt_uc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\ldap_schema.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\ldap_utf8.h
+# End Source File
+# Begin Source File
+
SOURCE=..\libldap\modify.c
# End Source File
# Begin Source File
#include <ac/stdlib.h>
#include <ac/string.h>
#include <ac/time.h>
+#include <ac/queue.h>
#include "ldap-int.h"
#include "ldap_pvt_thread.h"
-#include "queue-compat.h"
+
#ifndef LDAP_THREAD_HAVE_TPOOL
int
ldap_int_thread_pool_shutdown ( void )
{
- ldap_int_thread_ctx_t *ctx;
struct ldap_int_thread_pool_s *pool;
while ((pool = STAILQ_FIRST(&ldap_int_thread_pool_list)) != NULL) {
for (l = i; l > 0; l--)
if (class >= uccombining_class((*out)[l-1]))
break;
- memmove(*out + l + 1, *out + l, (i - l) * sizeof(**out));
+ AC_MEMCPY(*out + l + 1, *out + l, (i - l) * sizeof(**out));
(*out)[l] = decomp[k];
}
i++;
for (l = i; l > 0; l--)
if (class >= uccombining_class((*out)[l-1]))
break;
- memmove(*out + l + 1, *out + l, (i - l) * sizeof(**out));
+ AC_MEMCPY(*out + l + 1, *out + l, (i - l) * sizeof(**out));
(*out)[l] = in[j];
}
i++;
#include <ac/string.h>
#include <ac/unistd.h>
+#undef ishdigit
#define ishdigit(cc) (((cc) >= '0' && (cc) <= '9') ||\
((cc) >= 'A' && (cc) <= 'F') ||\
((cc) >= 'a' && (cc) <= 'f'))
char * UTF8normalize(
struct berval *bv,
- char casefold )
+ unsigned casefold )
{
int i, j, len, clen, outpos, ucsoutlen, outsize, last;
char *out, *s;
int UTF8normcmp(
const char *s1,
const char *s2,
- char casefold )
+ unsigned casefold )
{
int i, l1, l2, len, ulen, res;
unsigned long *ucs, *ucsout1, *ucsout2;
# End Source File
# Begin Source File
+SOURCE=..\..\include\lutil_hash.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\include\lutil_ldap.h
# End Source File
# Begin Source File
*/
p = strchr( url, '%' );
if ( p != NULL ) {
- memmove( p + 3, p + 1, strlen( p + 1 ) + 1 );
+ AC_MEMCPY( p + 3, p + 1, strlen( p + 1 ) + 1 );
p[ 1 ] = '2';
p[ 2 ] = '5';
}
continue;
}
if ( p[ 1 ] == REWRITE_SUBMATCH_ESCAPE ) {
- memmove((char *)p, p + 1, strlen( p ) );
+ AC_MEMCPY((char *)p, p + 1, strlen( p ) );
continue;
}
AciSetCookie *cp = cookie;
BVarray bvals = NULL;
struct berval bv, ndn;
- int i;
/* this routine needs to return the bervals instead of
* plain strings, since syntax is not known. It should
cookie.e = e;
cookie.conn = conn;
cookie.op = op;
- rc = (set_filter(aci_set_gather, &cookie, &set, op->o_ndn.bv_val, e->e_ndn, NULL) > 0);
+ rc = (slap_set_filter(aci_set_gather, &cookie, &set,
+ op->o_ndn.bv_val, e->e_ndn, NULL) > 0);
ch_free(set.bv_val);
}
return(rc);
char *s = bv.bv_val;
ber_str2bv( UTF8normalize( bv.bv_val ? &bv
- : &ava->la_value, UTF8_CASEFOLD ),
+ : &ava->la_value, LDAP_UTF8_CASEFOLD ),
0, 0, &bv );
free( s );
}
ptr = (unsigned char *)bv->bv_val;
entry_putlen(&ptr, siz);
entry_putlen(&ptr, dnlen);
- memcpy(ptr, e->e_dn, dnlen);
+ AC_MEMCPY(ptr, e->e_dn, dnlen);
ptr += dnlen;
*ptr++ = '\0';
entry_putlen(&ptr, ndnlen);
- memcpy(ptr, e->e_ndn, ndnlen);
+ AC_MEMCPY(ptr, e->e_ndn, ndnlen);
ptr += ndnlen;
*ptr++ = '\0';
for (a=e->e_attrs; a; a=a->a_next) {
entry_putlen(&ptr, a->a_desc->ad_cname.bv_len);
- memcpy(ptr, a->a_desc->ad_cname.bv_val,
+ AC_MEMCPY(ptr, a->a_desc->ad_cname.bv_val,
a->a_desc->ad_cname.bv_len);
ptr += a->a_desc->ad_cname.bv_len;
*ptr++ = '\0';
if( uidlen ) {
struct berval b2;
b2.bv_val = ch_malloc(dnlen + uidlen + 1);
- SAFEMEMCPY( b2.bv_val, normalized->bv_val, dnlen );
+ AC_MEMCPY( b2.bv_val, normalized->bv_val, dnlen );
/* restore the separator */
*uid = '#';
/* shift the UID */
- SAFEMEMCPY( normalized->bv_val+dnlen, uid, uidlen );
+ AC_MEMCPY( normalized->bv_val+dnlen, uid, uidlen );
b2.bv_len = dnlen + uidlen;
normalized->bv_val[dnlen+uidlen] = '\0';
free(normalized->bv_val);
static SubstringsAssertion *
UTF8SubstringsassertionNormalize(
SubstringsAssertion *sa,
- char casefold )
+ unsigned casefold )
{
SubstringsAssertion *nsa;
int i;
while( *++q & 0x80 ) {
/* empty */
}
- p = memmove(p, q, strlen(q) + 1);
+ p = AC_MEMCPY(p, q, strlen(q) + 1);
} else {
p++;
}
size_t avlen;
/* Yes, this is necessary */
- nval = UTF8normalize( value, UTF8_NOCASEFOLD );
+ nval = UTF8normalize( value, LDAP_UTF8_NOCASEFOLD );
if( nval == NULL ) {
*matchp = 1;
return LDAP_SUCCESS;
/* Yes, this is necessary */
assertv = UTF8normalize( ((struct berval *)assertedValue),
- UTF8_NOCASEFOLD );
+ LDAP_UTF8_NOCASEFOLD );
if( assertv == NULL ) {
ch_free( nval );
*matchp = 1;
for( j=0; values[j].bv_val != NULL; j++ ) {
/* Yes, this is necessary */
- val = UTF8normalize( &values[j], UTF8_NOCASEFOLD );
+ val = UTF8normalize( &values[j], LDAP_UTF8_NOCASEFOLD );
strip8bitChars( val );
/* Isolate how many words there are. There will be a key for each */
/* Allocate/increase storage to account for new keys */
newkeys = (struct berval *)ch_malloc( (keycount + wordcount + 1)
* sizeof(struct berval) );
- memcpy( newkeys, keys, keycount * sizeof(struct berval) );
+ AC_MEMCPY( newkeys, keys, keycount * sizeof(struct berval) );
if( keys ) ch_free( keys );
keys = newkeys;
/* Yes, this is necessary */
val = UTF8normalize( ((struct berval *)assertValue),
- UTF8_NOCASEFOLD );
+ LDAP_UTF8_NOCASEFOLD );
if( val == NULL ) {
keys = (struct berval *)ch_malloc( sizeof(struct berval) );
keys[0].bv_val = NULL;
{
*matchp = UTF8normcmp( value->bv_val,
((struct berval *) assertedValue)->bv_val,
- UTF8_NOCASEFOLD );
+ LDAP_UTF8_NOCASEFOLD );
return LDAP_SUCCESS;
}
struct berval left;
int i;
ber_len_t inlen=0;
- char *nav, casefold;
+ char *nav;
+ unsigned casefold;
casefold = strcmp( mr->smr_oid, caseExactSubstringsMatchOID )
- ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+ ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
nav = UTF8normalize( value, casefold );
if( nav == NULL ) {
BVarray *keysp )
{
int i;
- char casefold;
+ unsigned casefold;
size_t slen, mlen;
BVarray keys;
HASH_CONTEXT HASHcontext;
mlen = mr->smr_oidlen;
casefold = strcmp( mr->smr_oid, caseExactMatchOID )
- ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+ ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
for( i=0; values[i].bv_val != NULL; i++ ) {
struct berval value;
void * assertValue,
BVarray *keysp )
{
- char casefold;
+ unsigned casefold;
size_t slen, mlen;
BVarray keys;
HASH_CONTEXT HASHcontext;
mlen = mr->smr_oidlen;
casefold = strcmp( mr->smr_oid, caseExactMatchOID )
- ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+ ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
ber_str2bv( UTF8normalize( ((struct berval *) assertValue), casefold ),
0, 0, &value );
BVarray values,
BVarray *keysp )
{
- char casefold;
+ unsigned casefold;
ber_len_t i, nkeys;
size_t slen, mlen;
BVarray keys;
assert( i > 0 );
casefold = strcmp( mr->smr_oid, caseExactSubstringsMatchOID )
- ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+ ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
nvalues = ch_malloc( sizeof( struct berval ) * (i+1) );
for( i=0; values[i].bv_val != NULL; i++ ) {
BVarray *keysp )
{
SubstringsAssertion *sa;
- char pre, casefold;
+ char pre;
+ unsigned casefold;
ber_len_t nkeys = 0;
size_t slen, mlen, klen;
BVarray keys;
struct berval digest;
casefold = strcmp( mr->smr_oid, caseExactSubstringsMatchOID )
- ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+ ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
sa = UTF8SubstringsassertionNormalize( assertValue, casefold );
if( sa == NULL ) {
{
*matchp = UTF8normcmp( value->bv_val,
((struct berval *) assertedValue)->bv_val,
- UTF8_CASEFOLD );
+ LDAP_UTF8_CASEFOLD );
return LDAP_SUCCESS;
}
if( negative ) {
normalized->bv_val[0] = '-';
}
- memcpy( normalized->bv_val + negative, p, len );
+ AC_MEMCPY( normalized->bv_val + negative, p, len );
}
return LDAP_SUCCESS;
X509_free(xcert);
- out->bv_len = serial->bv_len + 3 + issuer_dn->bv_len + 1;
+ out->bv_len = serial->bv_len + issuer_dn->bv_len + sizeof(" $ ");
out->bv_val = ch_malloc(out->bv_len);
p = out->bv_val;
AC_MEMCPY(p, serial->bv_val, serial->bv_len);
p += serial->bv_len;
- AC_MEMCPY(p, " $ ", 3);
+ AC_MEMCPY(p, " $ ", sizeof(" $ ")-1);
p += 3;
AC_MEMCPY(p, issuer_dn->bv_val, issuer_dn->bv_len);
p += issuer_dn->bv_len;
return LDAP_INVALID_SYNTAX;
}
- for ( p++; ( p < e ) && ( *p != ')' ); p++ ) {
+ for ( p++; ( p < e ) && ( *p != /*'('*/ ')' ); p++ ) {
if ( *p == ',' ) {
commas++;
if ( commas > 2 ) {
struct slap_internal_schema slap_schema;
-#define objectClassIndexer NULL
-#define objectClassFilter NULL
-
static int
objectClassMatch(
int *matchp,
Debug( LDAP_DEBUG_TRACE, "objectClassMatch(%s,%s) = %d\n",
value->bv_val, a->bv_val, *matchp );
#endif
-
#endif
return LDAP_SUCCESS;
}
-#define structuralObjectClassIndexer NULL
-#define structuralObjectClassFilter NULL
-
static int
structuralObjectClassMatch(
int *matchp,
size_t ssam_offset;
} ad_map[] = {
{ "objectClass",
- objectClassMatch, objectClassIndexer, objectClassFilter,
+ objectClassMatch, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_objectClass) },
{ "structuralObjectClass",
- structuralObjectClassMatch,
- structuralObjectClassIndexer, structuralObjectClassFilter,
+ structuralObjectClassMatch, NULL, NULL,
offsetof(struct slap_internal_schema, si_ad_structuralObjectClass) },
/* user entry operational attributes */
{ "1.1.1", NULL, NULL, 1, NULL,
NULL, NULL, NULL, NULL,
0, 0, 0, 1, 3 }, /* LDAPAttributeType */
- { sizeof( "UNDEFINED" ) - 1, "UNDEFINED" }, /* cname */
+ { sizeof("UNDEFINED")-1, "UNDEFINED" }, /* cname */
NULL, /* sup */
NULL, /* subtypes */
NULL, NULL, NULL, NULL, /* matching rules */
if( pos ) {
int suflen = strlen(oid + pos);
- char *new = ch_malloc( om->som_oid.bv_len
+ char *tmp = ch_malloc( om->som_oid.bv_len
+ suflen + 1);
- strcpy(new, om->som_oid.bv_val);
-
+ strcpy(tmp, om->som_oid.bv_val);
if( suflen ) {
suflen = om->som_oid.bv_len;
- new[suflen++] = '.';
- strcpy(new+suflen, oid+pos+1);
+ tmp[suflen++] = '.';
+ strcpy(tmp+suflen, oid+pos+1);
}
- return new;
+ return tmp;
}
}
}
Connection *conn, /* where to send results */
Operation *op /* info about the op to which we're responding */
) {
- int i;
ber_int_t scope, deref, attrsonly;
ber_int_t sizelimit, timelimit;
struct berval base = { 0, NULL };
"do_search \"%s\" %d %d %d %d %d\n", base.bv_val, scope,
deref, sizelimit, timelimit, attrsonly ));
#else
- Debug( LDAP_DEBUG_ARGS, "SRCH \"%s\" %d %d", base.bv_val, scope, deref );
- Debug( LDAP_DEBUG_ARGS, " %d %d %d\n", sizelimit, timelimit,
- attrsonly);
+ Debug( LDAP_DEBUG_ARGS, "SRCH \"%s\" %d %d",
+ base.bv_val, scope, deref );
+ Debug( LDAP_DEBUG_ARGS, " %d %d %d\n",
+ sizelimit, timelimit, attrsonly);
#endif
/* filter - returns a "normalized" version */
#include "sets.h"
static BVarray set_join (BVarray lset, int op, BVarray rset);
-static BVarray set_chase (SET_GATHER gatherer,
+static BVarray set_chase (SLAP_SET_GATHER gatherer,
void *cookie, BVarray set, struct berval *attr, int closure);
static int set_samedn (char *dn1, char *dn2);
long
-set_size (BVarray set)
+slap_set_size (BVarray set)
{
int i;
}
void
-set_dispose (BVarray set)
+slap_set_dispose (BVarray set)
{
bvarray_free(set);
}
return(ch_calloc(1, sizeof(struct berval)));
return(lset);
}
- set_dispose(lset);
+ slap_set_dispose(lset);
return(rset);
}
if (rset == NULL || rset->bv_val == NULL) {
- set_dispose(rset);
+ slap_set_dispose(rset);
return(lset);
}
- i = set_size(lset) + set_size(rset) + 1;
+ i = slap_set_size(lset) + slap_set_size(rset) + 1;
set = ch_calloc(i, sizeof(struct berval));
if (set != NULL) {
/* set_chase() depends on this routine to
} else {
set = lset;
lset = NULL;
- last = set_size(set) - 1;
+ last = slap_set_size(set) - 1;
for (i = 0; set[i].bv_val; i++) {
for (j = 0; rset[j].bv_val; j++) {
if (set_samedn(set[i].bv_val, rset[j].bv_val))
}
}
- set_dispose(lset);
- set_dispose(rset);
+ slap_set_dispose(lset);
+ slap_set_dispose(rset);
return(set);
}
static BVarray
-set_chase (SET_GATHER gatherer,
+set_chase (SLAP_SET_GATHER gatherer,
void *cookie, BVarray set, struct berval *attr, int closure)
{
BVarray vals, nset;
return(set);
if (attr->bv_len > (sizeof(attrstr) - 1)) {
- set_dispose(set);
+ slap_set_dispose(set);
return(NULL);
}
AC_MEMCPY(attrstr, attr->bv_val, attr->bv_len);
nset = ch_calloc(1, sizeof(struct berval));
if (nset == NULL) {
- set_dispose(set);
+ slap_set_dispose(set);
return(NULL);
}
for (i = 0; set[i].bv_val; i++) {
if (vals != NULL)
nset = set_join(nset, '|', vals);
}
- set_dispose(set);
+ slap_set_dispose(set);
if (closure) {
for (i = 0; nset[i].bv_val; i++) {
}
int
-set_filter (SET_GATHER gatherer,
- void *cookie, struct berval *fbv, char *user, char *this, BVarray *results)
+slap_set_filter (SLAP_SET_GATHER gatherer,
+ void *cookie, struct berval *fbv,
+ char *user, char *this, BVarray *results)
{
#define IS_SET(x) ( (long)(x) >= 256 )
#define IS_OP(x) ( (long)(x) < 256 )
} else if (SF_TOP() != (void *)'/') {
SF_ERROR(syntax);
} else {
- SF_POP();
struct berval fb2;
+ SF_POP();
fb2.bv_val = filter;
fb2.bv_len = len;
set = set_chase(gatherer,
SF_ERROR(syntax);
}
- rc = set_size(set);
+ rc = slap_set_size(set);
if (results) {
*results = set;
set = NULL;
_error:
if (IS_SET(set))
- set_dispose(set);
+ slap_set_dispose(set);
while ((set = SF_POP())) {
if (IS_SET(set))
- set_dispose(set);
+ slap_set_dispose(set);
}
return(rc);
}
* also return the syntax or some "comparison cookie"
* that is used by set_filter.
*/
-typedef BVarray (SET_GATHER) (void *cookie, char *name, struct berval *attr);
+typedef BVarray (SLAP_SET_GATHER)(
+ void *cookie, char *name, struct berval *attr);
-LDAP_SLAPD_F (long) set_size (BVarray set);
-LDAP_SLAPD_F (void) set_dispose (BVarray set);
+LDAP_SLAPD_F (long) slap_set_size (BVarray set);
+LDAP_SLAPD_F (void) slap_set_dispose (BVarray set);
LDAP_SLAPD_F (int)
-set_filter (SET_GATHER gatherer, void *cookie, struct berval *filter,
- char *user, char *this, BVarray *results);
+slap_set_filter (SLAP_SET_GATHER gatherer,
+ void *cookie, struct berval *filter,
+ char *user, char *this, BVarray *results);
return NULL;
break;
- default:
- if ( ldap_pvt_find_wildcard( value ) == NULL ) {
- f->f_choice = LDAP_FILTER_EQUALITY;
- } else if ( strcmp( value, "*" ) == 0 ) {
- f->f_choice = LDAP_FILTER_PRESENT;
- } else {
- f->f_choice = LDAP_FILTER_SUBSTRINGS;
- f->f_sub = ch_calloc( 1, sizeof( SubstringsAssertion ) );
- rc = slap_str2ad( str, &f->f_sub_desc, &text );
- if( rc != LDAP_SUCCESS ) {
+ default: {
+ char *nextstar = ldap_pvt_find_wildcard( value );
+ if ( nextstar == NULL ) {
filter_free( f );
*(value-1) = '=';
return NULL;
- }
- if ( str2subvals( value, f ) != 0 ) {
- filter_free( f );
+ } else if ( nextstar == '\0' ) {
+ f->f_choice = LDAP_FILTER_EQUALITY;
+ } else if ( strcmp( value, "*" ) == 0 ) {
+ f->f_choice = LDAP_FILTER_PRESENT;
+ } else {
+ f->f_choice = LDAP_FILTER_SUBSTRINGS;
+ f->f_sub = ch_calloc( 1, sizeof( SubstringsAssertion ) );
+ rc = slap_str2ad( str, &f->f_sub_desc, &text );
+ if( rc != LDAP_SUCCESS ) {
+ filter_free( f );
+ *(value-1) = '=';
+ return NULL;
+ }
+ if ( str2subvals( value, f ) != 0 ) {
+ filter_free( f );
+ *(value-1) = '=';
+ return( NULL );
+ }
*(value-1) = '=';
- return( NULL );
+ return( f );
}
- *(value-1) = '=';
- return( f );
- }
- break;
+ } break;
}
if ( f->f_choice == LDAP_FILTER_PRESENT ) {
{
char *nextstar, *val, *freeme;
int gotstar;
+ int final;
#ifdef NEW_LOGGING
LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY,
if( in == NULL ) return 0;
val = freeme = ch_strdup( in );
- gotstar = 0;
+ gotstar = final = 0;
while ( *val ) {
- if ( (nextstar = ldap_pvt_find_wildcard( val )) != NULL )
- *nextstar++ = '\0';
+ nextstar = ldap_pvt_find_wildcard( val );
- ldap_pvt_filter_value_unescape( val );
+ if ( nextstar == NULL ) {
+ free( freeme );
+ return -1;
+ }
- if ( gotstar == 0 ) {
- ber_str2bv( val, 0, 1, &f->f_sub_initial );
+ if( *nextstar == '\0' ) {
+ final = 1;
+ } else {
+ gotstar++;
+ *nextstar = '\0';
+ }
- } else if ( nextstar == NULL ) {
+ ldap_pvt_filter_value_unescape( val );
+
+ if ( final ) {
ber_str2bv( val, 0, 1, &f->f_sub_final );
+ } else if ( gotstar <= 1 ) {
+ ber_str2bv( val, 0, 1, &f->f_sub_initial );
+
} else {
charray_add( (char ***) &f->f_sub_any, (char *) ber_bvstrdup( val ) );
}
- gotstar = 1;
- val = nextstar;
+ val = nextstar+1;
}
free( freeme );