]> git.sur5r.net Git - openldap/commitdiff
Rework filter code
authorKurt Zeilenga <kurt@openldap.org>
Wed, 2 Jan 2002 17:06:56 +0000 (17:06 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 2 Jan 2002 17:06:56 +0000 (17:06 +0000)
Misc cleanup / lint removal

30 files changed:
build/main.dsw
include/ldap_pvt.h
include/ldap_pvt_uc.h
libraries/liblber/decode.c
libraries/liblber/liblber.dsp
libraries/libldap/compare.c
libraries/libldap/cyrus.c
libraries/libldap/getdn.c
libraries/libldap/libldap.dsp
libraries/libldap/search.c
libraries/libldap/utf-8.c
libraries/libldap/util-int.c
libraries/libldap_r/libldap_r.dsp
libraries/libldap_r/tpool.c
libraries/liblunicode/ucdata/ucdata.c
libraries/liblunicode/ucdata/ucgendat.c
libraries/liblunicode/ucstr.c
libraries/liblutil/liblutil.dsp
libraries/librewrite/map.c
libraries/librewrite/subst.c
servers/slapd/acl.c
servers/slapd/dn.c
servers/slapd/entry.c
servers/slapd/schema_init.c
servers/slapd/schema_prep.c
servers/slapd/schemaparse.c
servers/slapd/search.c
servers/slapd/sets.c
servers/slapd/sets.h
servers/slapd/str2filter.c

index 13475f4a66c9f5a0d587a3c57758a02ca919071c..3b8c2ce99896be85ef2747b5a9d10f0bea3c5eea 100644 (file)
@@ -149,6 +149,33 @@ Package=<4>
     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
 }}}
 
 ###############################################################################
@@ -183,6 +210,27 @@ Package=<4>
 
 ###############################################################################
 
+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>
index 82ab24d25817d60bcdc776b92eaf9751b12a5d3d..c6af0fb819b3078ae40c001a40cd60e67cab1ddb 100644 (file)
@@ -17,7 +17,6 @@
 #ifndef _LDAP_PVT_H
 #define _LDAP_PVT_H 1
 
-#include <ldap_cdefs.h>
 #include <lber.h>                              /* get ber_slen_t */
 
 LDAP_BEGIN_DECL
@@ -107,6 +106,7 @@ LDAP_F (void) ldap_pvt_hex_unescape LDAP_P(( char *s ));
  * 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')
@@ -114,6 +114,12 @@ LDAP_F (void) ldap_pvt_hex_unescape LDAP_P(( char *s ));
 #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 */
index 6c1b3cfe6f1ff1f433a74a6c17443f4e4c9e7e9b..c5d74582586c1fbe0fe5db2b7d0a658f77119ac4 100644 (file)
@@ -18,7 +18,6 @@
 #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
@@ -79,13 +78,12 @@ LDAP_F (char*) ldap_utf8_strtok( char* sp, const char* sep, char **last);
 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) \
@@ -123,17 +121,17 @@ LDAP_LUNICODE_F(void) ucstr2upper(
        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
 
index 305e766a76f776a419380a88b0841bc77877e36e..488318db964670831d23c6702d9ddd591226fdde 100644 (file)
@@ -704,9 +704,7 @@ ber_scanf ( BerElement *ber,
                }
        }
 
-breakout:
        va_end( ap );
-
        if ( rc == LBER_DEFAULT ) {
            /*
             * Error.  Reclaim malloced memory that was given to the caller.
index e414c67d3efd5abe35107b9f42bf635f4fd577da..e02e1f3f762617076a1cf250fb1c4fe153aa114c 100644 (file)
@@ -219,10 +219,6 @@ SOURCE=.\options.c
 # 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
index 2b890b1fe9d7af4f47646f54b9bb5f93b162121c..1a4fed1b3566ca591f2bd6c7e154f0873ead2c70 100644 (file)
@@ -36,7 +36,7 @@
  * 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 )
index 390ae47400a0580eb973c51d392ef4af34447f58..8f3c5282da234ba942f481752cc161b44bcff066 100644 (file)
@@ -161,7 +161,7 @@ sb_sasl_drop_packet ( Sockbuf_Buf *sec_buf_in, int debuglevel )
 
        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 ) {
index 41db8756bd3251ff0bd9e647055b65f33ca59fb3..76bc499463702d1adf5de93f0be0842b549c8024 100644 (file)
@@ -354,25 +354,21 @@ ldap_dn_normalize( const char *dnin, unsigned fin, char **dnout, unsigned fout )
  */
 #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) )
@@ -655,7 +651,6 @@ ldap_str2dn( const char *str, LDAPDN **dn, unsigned flags )
        }
 
        for ( ; p[ 0 ]; p++ ) {
-               LDAPDN          *dn;
                int             err;
                
                err = ldap_str2rdn( p, &newRDN, &p, flags );
@@ -3060,7 +3055,8 @@ got_funcs:
 
        }
 
-       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 );
 }
index b143f709d92f5efbd60ecf09bc0e5a8888047978..5548eff5ceb463a7f379bf463fb60b5a33e58fed 100644 (file)
@@ -183,6 +183,10 @@ SOURCE=.\extended.c
 # End Source File
 # Begin Source File
 
+SOURCE=.\filter.c
+# End Source File
+# Begin Source File
+
 SOURCE=.\free.c
 # End Source File
 # Begin Source File
index c4a223dfe31ad069bcbd6bd6a5268c4b0bf6b0d9..818f90e43cfc9b7a472becf4e88416ccfb19fa70 100644 (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.
@@ -334,7 +297,7 @@ ldap_build_search_req(
        } else {
                filter = LDAP_STRDUP( "(objectclass=*)" );
        }
-       err = put_filter( ber, filter );
+       err = ldap_int_put_filter( ber, filter );
        LDAP_FREE( filter );
 
        if ( err  == -1 ) {
@@ -364,583 +327,6 @@ ldap_build_search_req(
        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,
index 6a97a4fc457df5b249851e559cc873a88c6b3627..a5bcc029e6336cef52754d2138c2502f0e2ca1a4 100644 (file)
@@ -30,9 +30,6 @@
 #include "ldap-int.h"
 #include "ldap_defaults.h"
 
-#undef LDAP_IS_ASCII
-#define LDAP_IS_ASCII(uc)      ((uc) < 0x80)
-
 /*
  * Basic UTF-8 routines
  */
@@ -250,6 +247,7 @@ int ldap_utf8_copy( char* dst, const char *src )
        return i;
 }
 
+#ifndef UTF8_ALPHA_CTYPE
 /*
  * UTF-8 ctype routines
  * Only deals with characters < 0x80 (ie: US-ASCII)
@@ -258,34 +256,32 @@ int ldap_utf8_copy( char* dst, const char *src )
 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 ' ':
@@ -300,7 +296,6 @@ int ldap_utf8_isspace( const char * p )
        return 0;
 }
 
-#ifndef UTF8_ALPHA_CTYPE
 /*
  * These are not needed by the C SDK and are
  * not "good enough" for general use.
@@ -309,39 +304,36 @@ int ldap_utf8_isalpha( 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' )
-               || ( 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
 
index ffd221408188583f5ed92d32ba69f32e78ef8ad8..2473817aac5c8233e6ecf630500a2127fd7e4072 100644 (file)
@@ -92,8 +92,8 @@ char *ldap_pvt_ctime( const time_t *tp, char *buf )
 #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 );
 
index b8d32ff47a5ea2ed1859133977df3c589a07ab06..46a235863a3373ab1ea779fd7b55b6fbec7e3f8a 100644 (file)
@@ -184,6 +184,10 @@ SOURCE=..\libldap\extended.c
 # 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
@@ -228,10 +232,22 @@ SOURCE=..\..\include\ldap_cdefs.h
 # 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
@@ -244,6 +260,18 @@ SOURCE=..\..\include\ldap_pvt_thread.h
 # 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
index f0ea8db9bc4354ce05429089571328685a9247d4..b1b32957dad0de9a7cb620e1a38fdbd1b5f18f5d 100644 (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
 
@@ -72,7 +73,6 @@ ldap_int_thread_pool_startup ( void )
 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) {
index 172fbea326415809a3e1cc9cc2736360f8c35f6e..1c48a1d730001825cc3828015eda68683cacf69e 100644 (file)
@@ -816,7 +816,7 @@ uccanondecomp(const unsigned long *in, int inlen,
                     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++;
@@ -846,7 +846,7 @@ uccanondecomp(const unsigned long *in, int inlen,
                 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++;
index e7a9a563e7a77567842bea3f45a163e350dedc3e..4bab6d98802fb9bca32bd91f8dc5660f2e289f80 100644 (file)
@@ -30,6 +30,7 @@
 #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'))
index d970aa5a75317a7d7bfc211bd65dea81966d9792..43ab99ddf7904afa3046e8db46e89452380677de 100644 (file)
@@ -83,7 +83,7 @@ void ucstr2upper(
 
 char * UTF8normalize(
        struct berval *bv,
-       char casefold )
+       unsigned casefold )
 {
        int i, j, len, clen, outpos, ucsoutlen, outsize, last;
        char *out, *s;
@@ -219,7 +219,7 @@ char * UTF8normalize(
 int UTF8normcmp(
        const char *s1,
        const char *s2,
-       char casefold )
+       unsigned casefold )
 {
        int i, l1, l2, len, ulen, res;
        unsigned long *ucs, *ucsout1, *ucsout2;
index 613c9995f2798c1cbcdb5c8be189bd7e38b71ca8..a17939d6f35d2bceab481c2be4265f121aa5035a 100644 (file)
@@ -180,6 +180,10 @@ SOURCE=..\..\include\lutil.h
 # 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
index 9fbf330c3c2189a4d196f87753a53adc05c34b4b..816a27edf76dd3c4afa8c8648615c225b9b6124e 100644 (file)
@@ -187,7 +187,7 @@ rewrite_xmap_parse(
                 */
                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';
                }
index b85a7560bd59ec68e64b0de092c924e181f7436e..f84ed44c251f47cecc61f6994b2bf4412a67c7b3 100644 (file)
@@ -59,7 +59,7 @@ rewrite_subst_compile(
                        continue;
                } 
                if ( p[ 1 ] == REWRITE_SUBMATCH_ESCAPE ) {
-                       memmove((char *)p, p + 1, strlen( p ) );
+                       AC_MEMCPY((char *)p, p + 1, strlen( p ) );
                        continue;
                }
 
index 44e412958378cb890ae105382d0c321922ea1751..839bac7de631c0825a144e40560fd10c8f270f54 100644 (file)
@@ -1208,7 +1208,6 @@ aci_set_gather (void *cookie, char *name, struct berval *attr)
        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
@@ -1299,7 +1298,8 @@ aci_match_set (
                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);
index 0dfb081817f3ded6eb457a307fa6771c4627f68c..54a4a61e8ab60e636d5fddc85e28d6cd74abfc95 100644 (file)
@@ -277,7 +277,7 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
                                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 );
                        }
index 7b076196935c64853b54f2dd509043baca7cfdb4..6ae8ba512b075eb7f1f2da3c81e9cb28ab8a6d32 100644 (file)
@@ -511,17 +511,17 @@ int entry_encode(Entry *e, struct berval *bv)
        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';
index d452ae50200d1fc7e57b97c0fd1f285e2c794f8d..8f781d3338f995cb78f889c17751e040d79835bd 100644 (file)
@@ -303,12 +303,12 @@ nameUIDNormalize(
                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);
@@ -567,7 +567,7 @@ UTF8StringNormalize(
 static SubstringsAssertion *
 UTF8SubstringsassertionNormalize(
        SubstringsAssertion *sa,
-       char casefold )
+       unsigned casefold )
 {
        SubstringsAssertion *nsa;
        int i;
@@ -634,7 +634,7 @@ strip8bitChars(
                        while( *++q & 0x80 ) {
                                /* empty */
                        }
-                       p = memmove(p, q, strlen(q) + 1);
+                       p = AC_MEMCPY(p, q, strlen(q) + 1);
                } else {
                        p++;
                }
@@ -666,7 +666,7 @@ approxMatch(
        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;
@@ -675,7 +675,7 @@ approxMatch(
 
        /* Yes, this is necessary */
        assertv = UTF8normalize( ((struct berval *)assertedValue),
-                                UTF8_NOCASEFOLD );
+               LDAP_UTF8_NOCASEFOLD );
        if( assertv == NULL ) {
                ch_free( nval );
                *matchp = 1;
@@ -781,7 +781,7 @@ approxIndexer(
 
        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 */
@@ -796,7 +796,7 @@ approxIndexer(
                /* 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;
 
@@ -833,7 +833,7 @@ approxFilter(
 
        /* 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;
@@ -999,7 +999,7 @@ caseExactMatch(
 {
        *matchp = UTF8normcmp( value->bv_val,
                ((struct berval *) assertedValue)->bv_val,
-               UTF8_NOCASEFOLD );
+               LDAP_UTF8_NOCASEFOLD );
        return LDAP_SUCCESS;
 }
 
@@ -1017,10 +1017,11 @@ caseExactIgnoreSubstringsMatch(
        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 ) {
@@ -1172,7 +1173,7 @@ static int caseExactIgnoreIndexer(
        BVarray *keysp )
 {
        int i;
-       char casefold;
+       unsigned casefold;
        size_t slen, mlen;
        BVarray keys;
        HASH_CONTEXT   HASHcontext;
@@ -1194,7 +1195,7 @@ static int caseExactIgnoreIndexer(
        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;
@@ -1234,7 +1235,7 @@ static int caseExactIgnoreFilter(
        void * assertValue,
        BVarray *keysp )
 {
-       char casefold;
+       unsigned casefold;
        size_t slen, mlen;
        BVarray keys;
        HASH_CONTEXT   HASHcontext;
@@ -1248,7 +1249,7 @@ static int caseExactIgnoreFilter(
        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 );
@@ -1293,7 +1294,7 @@ static int caseExactIgnoreSubstringsIndexer(
        BVarray values,
        BVarray *keysp )
 {
-       char casefold;
+       unsigned casefold;
        ber_len_t i, nkeys;
        size_t slen, mlen;
        BVarray keys;
@@ -1315,7 +1316,7 @@ static int caseExactIgnoreSubstringsIndexer(
        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++ ) {
@@ -1475,7 +1476,8 @@ static int caseExactIgnoreSubstringsFilter(
        BVarray *keysp )
 {
        SubstringsAssertion *sa;
-       char pre, casefold;
+       char pre;
+       unsigned casefold;
        ber_len_t nkeys = 0;
        size_t slen, mlen, klen;
        BVarray keys;
@@ -1485,7 +1487,7 @@ static int caseExactIgnoreSubstringsFilter(
        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 ) {
@@ -1651,7 +1653,7 @@ caseIgnoreMatch(
 {
        *matchp = UTF8normcmp( value->bv_val,
                ((struct berval *) assertedValue)->bv_val,
-               UTF8_CASEFOLD );
+               LDAP_UTF8_CASEFOLD );
        return LDAP_SUCCESS;
 }
        
@@ -1855,7 +1857,7 @@ integerNormalize(
                if( negative ) {
                        normalized->bv_val[0] = '-';
                }
-               memcpy( normalized->bv_val + negative, p, len );
+               AC_MEMCPY( normalized->bv_val + negative, p, len );
        }
 
        return LDAP_SUCCESS;
@@ -3531,12 +3533,12 @@ certificateExactConvert(
 
        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;
@@ -4041,7 +4043,7 @@ nisNetgroupTripleValidate(
                return LDAP_INVALID_SYNTAX;
        }
 
-       for ( p++; ( p < e ) && ( *p != ')' ); p++ ) {
+       for ( p++; ( p < e ) && ( *p != /*'('*/ ')' ); p++ ) {
                if ( *p == ',' ) {
                        commas++;
                        if ( commas > 2 ) {
index c4a5fcc8ad8878688212c38edfbe9b68a43cbfd6..ae42f8c1b80069537f2da6ec80aad5e9274fc6e0 100644 (file)
@@ -21,9 +21,6 @@ int schema_init_done = 0;
 
 struct slap_internal_schema slap_schema;
 
-#define objectClassIndexer NULL
-#define objectClassFilter NULL
-
 static int
 objectClassMatch(
        int *matchp,
@@ -68,15 +65,11 @@ objectClassMatch(
        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,
@@ -144,11 +137,10 @@ static struct slap_schema_ad_map {
        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 */
@@ -225,7 +217,7 @@ static AttributeType slap_at_undefined = {
        { "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 */
index d9f6b6c106e931ea326709ed13ff520ecc979f78..5959b003cdff25906577c8ebbfece09dd68070fc 100644 (file)
@@ -116,16 +116,15 @@ find_oidm(char *oid)
 
                        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;
                        }
                }
        }
index 86ecc786db711303a6908dbb5843505a754c3c1a..435417b0711f04a9670320a351085edb76c1de96 100644 (file)
@@ -30,7 +30,6 @@ do_search(
     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 };
@@ -129,9 +128,10 @@ do_search(
                "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 */
index 5effb4b134581eb0d8b00227d1983a4fe6330225..4f2f617d34383288c075e900abd7a4392b331bf1 100644 (file)
 #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;
 
@@ -31,7 +31,7 @@ set_size (BVarray set)
 }
 
 void
-set_dispose (BVarray set)
+slap_set_dispose (BVarray set)
 {
        bvarray_free(set);
 }
@@ -50,15 +50,15 @@ set_join (BVarray lset, int op, BVarray rset)
                                        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
@@ -91,7 +91,7 @@ set_join (BVarray lset, int op, BVarray rset)
                } 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))
@@ -108,13 +108,13 @@ set_join (BVarray lset, int op, BVarray rset)
                }
        }
 
-       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;
@@ -129,7 +129,7 @@ set_chase (SET_GATHER gatherer,
                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);
@@ -137,7 +137,7 @@ set_chase (SET_GATHER gatherer,
 
        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++) {
@@ -145,7 +145,7 @@ set_chase (SET_GATHER gatherer,
                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++) {
@@ -192,8 +192,9 @@ set_samedn (char *dn1, char *dn2)
 }
 
 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 )
@@ -347,8 +348,8 @@ set_filter (SET_GATHER gatherer,
                        } 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,
@@ -380,7 +381,7 @@ set_filter (SET_GATHER gatherer,
                SF_ERROR(syntax);
        }
 
-       rc = set_size(set);
+       rc = slap_set_size(set);
        if (results) {
                *results = set;
                set = NULL;
@@ -388,10 +389,10 @@ set_filter (SET_GATHER gatherer,
 
 _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);
 }
index eb9cc5dc880f78dbd4a9a2ec27f059be1c689b06..0f2129afb701c26aba55830460e45f5ae46cd58b 100644 (file)
@@ -9,12 +9,14 @@
  * 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);
 
index d0cd38f1e91cecfc6293da7f3ab5fe6294029508..2f686094412988552c4542c1f583b3676c9af3ca 100644 (file)
@@ -227,29 +227,34 @@ str2simple( const char *str )
                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 ) {
@@ -287,6 +292,7 @@ str2subvals( const char *in, Filter *f )
 {
        char    *nextstar, *val, *freeme;
        int     gotstar;
+       int final;
 
 #ifdef NEW_LOGGING
        LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY,
@@ -299,26 +305,36 @@ str2subvals( const char *in, Filter *f )
        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 );