static struct berval BV_DELETEOLDRDN = BER_BVC("deleteoldrdn");
static struct berval BV_NEWSUP = BER_BVC("newsuperior");
-#define BVICMP(a,b) ((a)->bv_len != (b)->bv_len ? \
- (a)->bv_len - (b)->bv_len : strcasecmp((a)->bv_val, (b)->bv_val))
+#define BV_CASEMATCH(a, b) \
+ ((a)->bv_len == (b)->bv_len && 0 == strcasecmp((a)->bv_val, (b)->bv_val))
static int process_ldif_rec LDAP_P(( char *rbuf, int lineno ));
static int parse_ldif_control LDAP_P(( struct berval *val, LDAPControl ***pctrls ));
freeval[i] = freev;
if ( dn == NULL ) {
- if ( linenum+i == 1 && !BVICMP( btype+i, &BV_VERSION )) {
+ if ( linenum+i == 1 && BV_CASEMATCH( btype+i, &BV_VERSION )) {
int v;
if( vals[i].bv_len == 0 || lutil_atoi( &v, vals[i].bv_val) != 0 || v != 1 ) {
fprintf( stderr,
}
version++;
- } else if ( !BVICMP( btype+i, &BV_DN )) {
+ } else if ( BV_CASEMATCH( btype+i, &BV_DN )) {
dn = vals[i].bv_val;
idn = i;
}
i = idn+1;
/* Check for "control" tag after dn and before changetype. */
- if (!BVICMP( btype+i, &BV_CONTROL)) {
+ if ( BV_CASEMATCH( btype+i, &BV_CONTROL )) {
/* Parse and add it to the list of controls */
rc = parse_ldif_control( vals+i, &pctrls );
if (rc != 0) {
}
/* Check for changetype */
- if ( !BVICMP( btype+i, &BV_CHANGETYPE )) {
+ if ( BV_CASEMATCH( btype+i, &BV_CHANGETYPE )) {
#ifdef LIBERAL_CHANGETYPE_MODOP
/* trim trailing spaces (and log warning ...) */
int icnt;
}
#endif /* LIBERAL_CHANGETYPE_MODOP */
- if ( BVICMP( vals+i, &BV_MODIFYCT ) == 0 ) {
+ if ( BV_CASEMATCH( vals+i, &BV_MODIFYCT )) {
new_entry = 0;
expect_modop = 1;
- } else if ( BVICMP( vals+i, &BV_ADDCT ) == 0 ) {
+ } else if ( BV_CASEMATCH( vals+i, &BV_ADDCT )) {
new_entry = 1;
modop = LDAP_MOD_ADD;
- } else if ( BVICMP( vals+i, &BV_MODRDNCT ) == 0
- || BVICMP( vals+i, &BV_MODDNCT ) == 0
- || BVICMP( vals+i, &BV_RENAMECT ) == 0)
+ } else if ( BV_CASEMATCH( vals+i, &BV_MODRDNCT )
+ || BV_CASEMATCH( vals+i, &BV_MODDNCT )
+ || BV_CASEMATCH( vals+i, &BV_RENAMECT ))
{
i++;
if ( i >= lines )
goto short_input;
- if ( BVICMP( btype+i, &BV_NEWRDN )) {
+ if ( !BV_CASEMATCH( btype+i, &BV_NEWRDN )) {
fprintf( stderr, _("%s: expecting \"%s:\" but saw"
" \"%s:\" (line %d, entry \"%s\")\n"),
prog, BV_NEWRDN.bv_val, btype[i].bv_val, linenum+i, dn );
i++;
if ( i >= lines )
goto short_input;
- if ( BVICMP( btype+i, &BV_DELETEOLDRDN )) {
+ if ( !BV_CASEMATCH( btype+i, &BV_DELETEOLDRDN )) {
fprintf( stderr, _("%s: expecting \"%s:\" but saw"
" \"%s:\" (line %d, entry \"%s\")\n"),
prog, BV_DELETEOLDRDN.bv_val, btype[i].bv_val, linenum+i, dn );
deleteoldrdn = ( vals[i].bv_val[0] == '0' ) ? 0 : 1;
i++;
if ( i < lines ) {
- if ( BVICMP( btype+i, &BV_NEWSUP )) {
+ if ( !BV_CASEMATCH( btype+i, &BV_NEWSUP )) {
fprintf( stderr, _("%s: expecting \"%s:\" but saw"
" \"%s:\" (line %d, entry \"%s\")\n"),
prog, BV_NEWSUP.bv_val, btype[i].bv_val, linenum+i, dn );
i++;
}
got_all = 1;
- } else if ( BVICMP( vals+i, &BV_DELETECT ) == 0 ) {
+ } else if ( BV_CASEMATCH( vals+i, &BV_DELETECT )) {
got_all = delete_entry = 1;
} else {
fprintf( stderr,
/* Make sure all attributes with multiple values are contiguous */
for (; i<lines; i++) {
for (j=i+1; j<lines; j++) {
- if ( !BVICMP( btype+i, btype+j )) {
+ if ( BV_CASEMATCH( btype+i, btype+j )) {
nmods--;
/* out of order, move intervening attributes down */
if ( j != i+1 ) {
k = -1;
BER_BVZERO(&bv);
for (i=idn; i<lines; i++) {
- if ( !BVICMP( btype+i, &BV_DN )) {
+ if ( BV_CASEMATCH( btype+i, &BV_DN )) {
fprintf( stderr, _("%s: attributeDescription \"%s\":"
" (possible missing newline"
" after line %d, entry \"%s\"?)\n"),
prog, btype[i].bv_val, linenum+i - 1, dn );
}
- if ( BVICMP(btype+i,&bv)) {
+ if ( !BV_CASEMATCH( btype+i, &bv )) {
bvl[k++] = NULL;
bv = btype[i];
lm[j].mod_op = LDAP_MOD_ADD | LDAP_MOD_BVALUES;
expect_modop = 0;
expect_sep = 1;
- if ( BVICMP( btype+i, &BV_MODOPADD ) == 0 ) {
+ if ( BV_CASEMATCH( btype+i, &BV_MODOPADD )) {
modop = LDAP_MOD_ADD;
mops[i] = M_SEP;
nmods--;
- } else if ( BVICMP( btype+i, &BV_MODOPREPLACE ) == 0 ) {
+ } else if ( BV_CASEMATCH( btype+i, &BV_MODOPREPLACE )) {
/* defer handling these since they might have no values.
* Use the BVALUES flag to signal that these were
* deferred. If values are provided later, this
modop = LDAP_MOD_REPLACE;
mops[i] = modop | LDAP_MOD_BVALUES;
btype[i] = vals[i];
- } else if ( BVICMP( btype+i, &BV_MODOPDELETE ) == 0 ) {
+ } else if ( BV_CASEMATCH( btype+i, &BV_MODOPDELETE )) {
modop = LDAP_MOD_DELETE;
mops[i] = modop | LDAP_MOD_BVALUES;
btype[i] = vals[i];
- } else if ( BVICMP( btype+i, &BV_MODOPINCREMENT ) == 0 ) {
+ } else if ( BV_CASEMATCH( btype+i, &BV_MODOPINCREMENT )) {
modop = LDAP_MOD_INCREMENT;
mops[i] = M_SEP;
nmods--;
expect_modop = 1;
nmods--;
} else {
- if ( BVICMP( btype+i, &bv )) {
+ if ( !BV_CASEMATCH( btype+i, &bv )) {
fprintf( stderr, _("%s: wrong attributeType at"
" line %d, entry \"%s\"\n"),
prog, linenum+i, dn );
/* If prev op was deferred and matches this type,
* clear the flag
*/
- if ( (mops[i-1]&LDAP_MOD_BVALUES) && !BVICMP(btype+i,
- btype+i-1)) {
+ if ( (mops[i-1] & LDAP_MOD_BVALUES)
+ && BV_CASEMATCH( btype+i, btype+i-1 ))
+ {
mops[i-1] = M_SEP;
nmods--;
}
for (j=i+1; j<lines; j++) {
if ( mops[j] == M_SEP || mops[i] != mops[j] )
continue;
- if ( !BVICMP( btype+i, btype+j )) {
+ if ( BV_CASEMATCH( btype+i, btype+j )) {
nmods--;
/* out of order, move intervening attributes down */
if ( j != i+1 ) {
for (i=idn; i<lines; i++) {
if ( mops[i] == M_SEP )
continue;
- if ( mops[i] != mops[i-1] || BVICMP(btype+i,&bv)) {
+ if ( mops[i] != mops[i-1] || !BV_CASEMATCH( btype+i, &bv )) {
bvl[k++] = NULL;
bv = btype[i];
lm[j].mod_op = mops[i] | LDAP_MOD_BVALUES;