rework them slightly to avoid computations which might result in underflow.
Rename them for consistency with other berval routines.
Remove some utf8 lint.
LBER_F( int )
ber_bvarray_add LDAP_P(( BerVarray *p, BerValue *bv ));
-#define ber_memcmp(v1,v2) \
- ((v1)->bv_len == (v2)->bv_len ? \
- memcmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) : \
- (v1)->bv_len - (v2)->bv_len )
-
-#define ber_cmp(v1,v2) \
- ((v1)->bv_len == (v2)->bv_len ? \
- strcmp((v1)->bv_val, (v2)->bv_val) : \
- (v1)->bv_len - (v2)->bv_len )
-
-#define ber_casecmp(v1,v2) \
- ((v1)->bv_len == (v2)->bv_len ? \
- strcasecmp((v1)->bv_val, (v2)->bv_val) : \
- (v1)->bv_len - (v2)->bv_len )
-
-#define ber_charcmp(v1,c) \
- ((v1)->bv_len == 1 ? (v1)->bv_val[0] == c : 0)
+#define ber_bvcmp(v1,v2) \
+ ((v1)->bv_len < (v2)->bv_len \
+ ? -1 : ((v1)->bv_len > (v2)->bv_len \
+ ? 1 : memcmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
/*
* error.c
LBER_F( int )
ber_pvt_socket_set_nonblock LDAP_P(( ber_socket_t sd, int nb ));
+
+#if 0
+#define ber_bvstrcmp(v1,v2) \
+ ((v1)->bv_len < (v2)->bv_len \
+ ? -1 : ((v1)->bv_len > (v2)->bv_len \
+ ? 1 : strncmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
+#else
+ /* avoid strncmp() */
+#define ber_bvstrcmp(v1,v2) ber_bvcmp((v1),(v2))
+#endif
+
+#define ber_bvstrcasecmp(v1,v2) \
+ ((v1)->bv_len < (v2)->bv_len \
+ ? -1 : ((v1)->bv_len > (v2)->bv_len \
+ ? 1 : strncasecmp((v1)->bv_val, (v2)->bv_val, (v1)->bv_len) ))
+
+#define ber_bvccmp(v1,c) \
+ ((v1)->bv_len == 1 ? (v1)->bv_val[0] == c : 0)
+
LDAP_END_DECL
#endif
*/
/* mask of required bits in second octet */
-const char ldap_utf8_mintab[] = {
- 0x20, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x30, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
- 0x38, 0x80, 0x80, 0x80, 0x3c, 0x80, 0x00, 0x00 };
+#undef c
+#define c const char
+c ldap_utf8_mintab[] = {
+ (c)0x20, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80,
+ (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80,
+ (c)0x30, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80, (c)0x80,
+ (c)0x38, (c)0x80, (c)0x80, (c)0x80, (c)0x3c, (c)0x80, (c)0x00, (c)0x00 };
+#undef c
int ldap_utf8_charlen2( const char * p )
{
#include "slap.h"
#include "sets.h"
+#include "lber_pvt.h"
/*
* user is bound as somebody in the same namespace as
* the entry, OR the given dn matches the dn pattern
*/
- if ( ber_cmp( &b->a_dn_pat, &aci_bv_anonymous ) == 0 ) {
+ if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_anonymous ) == 0 ) {
if ( op->o_ndn.bv_len != 0 ) {
continue;
}
- } else if ( ber_cmp( &b->a_dn_pat, &aci_bv_users ) == 0 ) {
+ } else if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_users ) == 0 ) {
if ( op->o_ndn.bv_len == 0 ) {
continue;
}
- } else if ( ber_cmp( &b->a_dn_pat, &aci_bv_self ) == 0 ) {
+ } else if ( ber_bvcmp( &b->a_dn_pat, &aci_bv_self ) == 0 ) {
if ( op->o_ndn.bv_len == 0 ) {
continue;
}
} else if ( b->a_dn_style == ACL_STYLE_REGEX ) {
if ( b->a_dn_pat.bv_len != 1 ||
- ber_charcmp( &b->a_dn_pat, '*' ) != 0 ) {
+ ber_bvccmp( &b->a_dn_pat, '*' ) != 0 ) {
int ret = regex_matches( b->a_dn_pat.bv_val,
op->o_ndn.bv_val, e->e_ndn, matches );
if ( strcmp( b->a_dn_pat.bv_val, op->o_ndn.bv_val + odnlen - patlen ) != 0 )
continue;
-
}
}
* dn.c
*/
-#define dn_match(dn1, dn2) ( ber_cmp((dn1), (dn2)) == 0 )
+#define dn_match(dn1, dn2) ( ber_bvcmp((dn1), (dn2)) == 0 )
LDAP_SLAPD_F (int) dnValidate LDAP_P((
Syntax *syntax,
#define SLAP_INDEX_DEFAULT SLAP_INDEX_EQUALITY
-#define IS_SLAP_INDEX(mask, type) (((mask) & (type)) == (type) )
+#define IS_SLAP_INDEX(mask, type) (((mask) & (type)) == (type))
#define SLAP_INDEX_SUBSTR_TYPE 0x0F00UL