/* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-/* Portions
- * Copyright (c) 1994 Regents of the University of Michigan.
- * All rights reserved.
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2003 The OpenLDAP Foundation.
+ * All rights reserved.
*
- * getdn.c
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* Portions Copyright (c) 1994 Regents of the University of Michigan.
+ * All rights reserved.
*/
#include "portable.h"
/* parsing/printing routines */
static int str2strval( const char *str, ber_len_t stoplen, struct berval *val,
- const char **next, unsigned flags, unsigned *retFlags, void *ctx );
+ const char **next, unsigned flags, int *retFlags, void *ctx );
static int DCE2strval( const char *str, struct berval *val,
const char **next, unsigned flags, void *ctx );
static int IA52strval( const char *str, struct berval *val,
char *str;
LDAPAVA *ava = tmpRDN[ iAVA ];
- if ( ava->la_flags == LDAP_AVA_BINARY ) {
+ if ( ava->la_flags & LDAP_AVA_BINARY ) {
vl = 1 + 2 * ava->la_value.bv_len;
} else {
str = LDAP_MALLOC( l + 1 );
}
- if ( ava->la_flags == LDAP_AVA_BINARY ) {
+ if ( ava->la_flags & LDAP_AVA_BINARY ) {
str[ al++ ] = '#';
if ( binval2hexstr( &ava->la_value, &str[ al ] ) ) {
goto error_return;
#define LDAP_DC_ATTRU "DC"
#define LDAP_DN_IS_RDN_DC( r ) \
( (r) && (r)[0] && !(r)[1] \
- && ((r)[0]->la_flags == LDAP_AVA_STRING) \
+ && ((r)[0]->la_flags & LDAP_AVA_STRING) \
&& ((r)[0]->la_attr.bv_len == 2) \
&& (((r)[0]->la_attr.bv_val[0] == LDAP_DC_ATTR[0]) \
|| ((r)[0]->la_attr.bv_val[0] == LDAP_DC_ATTRU[0])) \
* '\' + HEXPAIR(p) -> unhex(p)
*/
static int
-str2strval( const char *str, ber_len_t stoplen, struct berval *val, const char **next, unsigned flags, unsigned *retFlags, void *ctx )
+str2strval( const char *str, ber_len_t stoplen, struct berval *val, const char **next, unsigned flags, int *retFlags, void *ctx )
{
const char *p, *end, *startPos, *endPos = NULL;
ber_len_t len, escapes;
val->bv_len = len;
if ( escapes == 0 ) {
- if ( *retFlags == LDAP_AVA_NONPRINTABLE ) {
+ if ( *retFlags & LDAP_AVA_NONPRINTABLE ) {
val->bv_val = LDAP_MALLOCX( len + 1, ctx );
AC_MEMCPY( val->bv_val, startPos, len );
val->bv_val[ len ] = '\0';
/* len(type) + '=' + ',' | '/' */
l += ava->la_attr.bv_len + 2;
- switch ( ava->la_flags ) {
- case LDAP_AVA_BINARY:
+ if ( ava->la_flags & LDAP_AVA_BINARY ) {
/* octothorpe + twice the length */
l += 1 + 2 * ava->la_value.bv_len;
- break;
-
- case LDAP_AVA_STRING: {
+ } else {
ber_len_t vl;
unsigned f = flags | ava->la_flags;
return( -1 );
}
l += vl;
- break;
- }
-
- default:
- return( -1 );
}
}
str[ l++ ] = '=';
- switch ( ava->la_flags ) {
- case LDAP_AVA_BINARY:
+ if ( ava->la_flags & LDAP_AVA_BINARY ) {
str[ l++ ] = '#';
if ( binval2hexstr( &ava->la_value, &str[ l ] ) ) {
return( -1 );
}
l += 2 * ava->la_value.bv_len;
- break;
-
- case LDAP_AVA_STRING: {
+ } else {
ber_len_t vl;
unsigned f = flags | ava->la_flags;
return( -1 );
}
l += vl;
- break;
- }
-
- default:
- return( -1 );
}
}
l++;
/* FIXME: are binary values allowed in UFN? */
- switch ( ava->la_flags ) {
- case LDAP_AVA_BINARY:
+ if ( ava->la_flags & LDAP_AVA_BINARY ) {
/* octothorpe + twice the value */
l += 1 + 2 * ava->la_value.bv_len;
- break;
-
- case LDAP_AVA_STRING: {
+ } else {
ber_len_t vl;
unsigned f = flags | ava->la_flags;
return( -1 );
}
l += vl;
- break;
- }
-
- default:
- return( -1 );
}
}
str[ l++ ] = ( iAVA ? ',' : '/' );
}
- switch ( ava->la_flags ) {
- case LDAP_AVA_BINARY:
+ if ( ava->la_flags & LDAP_AVA_BINARY ) {
str[ l++ ] = '#';
if ( binval2hexstr( &ava->la_value, &str[ l ] ) ) {
return( -1 );
}
l += 2 * ava->la_value.bv_len;
- break;
-
- case LDAP_AVA_STRING: {
+ } else {
ber_len_t vl;
unsigned f = flags | ava->la_flags;
return( -1 );
}
l += vl;
- break;
- }
-
- default:
- return( -1 );
}
}
}
iRDN--;
- if ( iRDN && dn2domain( dn, bv, 0, &iRDN ) ) {
+ if ( iRDN && dn2domain( dn, bv, 0, &iRDN ) != 0 ) {
for ( l = bv->bv_len; iRDN >= 0 ; iRDN-- ) {
ber_len_t rdnl;
}
}
}
- Val.bv_val = str->data;
+ Val.bv_val = (char *) str->data;
Val.bv_len = str->length;
switch( str->type ) {
case V_ASN1_UNIVERSALSTRING: