1 /* value.c - routines for dealing with values */
7 #include <sys/socket.h>
14 struct berval ***vals,
15 struct berval **addvals,
23 if ( *maxvals == 0 ) {
26 need = nvals + naddvals + 1;
27 while ( *maxvals < need ) {
29 *vals = (struct berval **) ch_realloc( (char *) *vals,
30 *maxvals * sizeof(struct berval *) );
33 for ( i = 0, j = 0; i < naddvals; i++, j++ ) {
34 if ( addvals[i]->bv_len > 0 ) {
35 (*vals)[nvals + j] = ber_bvdup( addvals[i] );
38 (*vals)[nvals + j] = NULL;
45 struct berval ***vals,
46 struct berval **addvals
51 for ( nn = 0; addvals != NULL && addvals[nn] != NULL; nn++ )
54 if ( *vals == NULL ) {
55 *vals = (struct berval **) ch_malloc( (nn + 1)
56 * sizeof(struct berval *) );
59 for ( n = 0; (*vals)[n] != NULL; n++ )
61 *vals = (struct berval **) ch_realloc( (char *) *vals,
62 (n + nn + 1) * sizeof(struct berval *) );
65 for ( i = 0, j = 0; i < nn; i++ ) {
66 if ( addvals[i]->bv_len > 0 ) {
67 (*vals)[n + j++] = ber_bvdup( addvals[i] );
70 (*vals)[n + j] = NULL;
83 if ( ! (syntax & SYNTAX_CIS) ) {
87 if ( syntax & SYNTAX_DN ) {
88 (void) dn_normalize_case( s );
93 for ( d = s; *s; s++ ) {
94 if ( (syntax & SYNTAX_TEL) && (*s == ' ' || *s == '-') ) {
102 #define MIN( a, b ) (a < b ? a : b )
109 int normalize /* 1 => arg 1; 2 => arg 2; 3 => both */
113 struct stat st1, st2;
115 if ( normalize & 1 ) {
116 v1 = ber_bvdup( v1 );
117 value_normalize( v1->bv_val, syntax );
119 if ( normalize & 2 ) {
120 v2 = ber_bvdup( v2 );
121 value_normalize( v2->bv_val, syntax );
126 case (SYNTAX_CIS | SYNTAX_TEL):
127 case (SYNTAX_CIS | SYNTAX_DN):
128 rc = strcasecmp( v1->bv_val, v2->bv_val );
132 rc = strcmp( v1->bv_val, v2->bv_val );
136 rc = memcmp( v1->bv_val, v2->bv_val, MIN( v1->bv_len,
141 if ( normalize & 1 ) {
144 if ( normalize & 2 ) {
162 if ( normalize & 1 ) {
163 v1 = ber_bvdup( v1 );
164 value_normalize( v1->bv_val, syntax );
166 if ( normalize & 2 ) {
167 v2 = ber_bvdup( v2 );
168 value_normalize( v2->bv_val, syntax );
173 case (SYNTAX_CIS | SYNTAX_TEL):
174 rc = strncasecmp( v1->bv_val, v2->bv_val, len );
178 rc = strncmp( v1->bv_val, v2->bv_val, len );
182 rc = memcmp( v1->bv_val, v2->bv_val, len );
185 if ( normalize & 1 ) {
188 if ( normalize & 2 ) {
197 struct berval **vals,
205 for ( i = 0; vals[i] != NULL; i++ ) {
206 if ( value_cmp( vals[i], v, syntax, normalize ) == 0 ) {