1 /* value.c - routines for dealing with values */
18 struct berval ***vals,
19 struct berval **addvals,
27 if ( *maxvals == 0 ) {
30 need = nvals + naddvals + 1;
31 while ( *maxvals < need ) {
33 *vals = (struct berval **) ch_realloc( (char *) *vals,
34 *maxvals * sizeof(struct berval *) );
37 for ( i = 0, j = 0; i < naddvals; i++, j++ ) {
38 if ( addvals[i]->bv_len > 0 ) {
39 (*vals)[nvals + j] = ber_bvdup( addvals[i] );
42 (*vals)[nvals + j] = NULL;
49 struct berval ***vals,
50 struct berval **addvals
55 for ( nn = 0; addvals != NULL && addvals[nn] != NULL; nn++ )
58 if ( *vals == NULL ) {
59 *vals = (struct berval **) ch_malloc( (nn + 1)
60 * sizeof(struct berval *) );
63 for ( n = 0; (*vals)[n] != NULL; n++ )
65 *vals = (struct berval **) ch_realloc( (char *) *vals,
66 (n + nn + 1) * sizeof(struct berval *) );
69 for ( i = 0, j = 0; i < nn; i++ ) {
70 if ( addvals[i]->bv_len > 0 ) {
71 (*vals)[n + j++] = ber_bvdup( addvals[i] );
74 (*vals)[n + j] = NULL;
87 if ( ! (syntax & SYNTAX_CIS) ) {
91 if ( syntax & SYNTAX_DN ) {
92 (void) dn_normalize_case( s );
97 for ( d = s; *s; s++ ) {
98 if ( (syntax & SYNTAX_TEL) && (*s == ' ' || *s == '-') ) {
101 *d++ = TOUPPER( (unsigned char) *s );
111 int normalize /* 1 => arg 1; 2 => arg 2; 3 => both */
116 if ( normalize & 1 ) {
117 v1 = ber_bvdup( v1 );
118 value_normalize( v1->bv_val, syntax );
120 if ( normalize & 2 ) {
121 v2 = ber_bvdup( v2 );
122 value_normalize( v2->bv_val, syntax );
127 case (SYNTAX_CIS | SYNTAX_TEL):
128 case (SYNTAX_CIS | SYNTAX_DN):
129 rc = strcasecmp( v1->bv_val, v2->bv_val );
133 rc = strcmp( v1->bv_val, v2->bv_val );
137 rc = (v1->bv_len == v2->bv_len
138 ? memcmp( v1->bv_val, v2->bv_val, v1->bv_len )
139 : v1->bv_len > v2->bv_len ? 1 : -1);
143 if ( normalize & 1 ) {
146 if ( normalize & 2 ) {
155 struct berval **vals,
163 for ( i = 0; vals[i] != NULL; i++ ) {
164 if ( value_cmp( vals[i], v, syntax, normalize ) == 0 ) {