]> git.sur5r.net Git - openldap/blob - servers/slapd/entry.c
346bb87b83b8c0fcc76b0825b4d0c1313aea542c
[openldap] / servers / slapd / entry.c
1 /* entry.c - routines for dealing with entries */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #include "portable.h"
9
10 #include <stdio.h>
11
12 #include <ac/ctype.h>
13 #include <ac/errno.h>
14 #include <ac/socket.h>
15 #include <ac/string.h>
16
17 #include "slap.h"
18 #include "ldif.h"
19
20 static unsigned char    *ebuf;  /* buf returned by entry2str             */
21 static unsigned char    *ecur;  /* pointer to end of currently used ebuf */
22 static int              emaxsize;/* max size of ebuf                     */
23
24 /*
25  * Empty root entry
26  */
27 const Entry slap_entry_root = {
28         NOID, { 0, "" }, { 0, "" }, NULL, 0, { 0, "" }, NULL
29 };
30
31 int entry_destroy(void)
32 {
33         if ( ebuf ) free( ebuf );
34         ebuf = NULL;
35         ecur = NULL;
36         emaxsize = 0;
37         return 0;
38 }
39
40
41 Entry *
42 str2entry( char *s )
43 {
44         int rc;
45         Entry           *e;
46         char            *type;
47         struct berval   vals[2];
48 #ifdef SLAP_NVALUES
49         struct berval   nvals[2], *nvalsp;
50 #endif
51         AttributeDescription *ad;
52         const char *text;
53         char    *next;
54
55         /*
56          * LDIF is used as the string format.
57          * An entry looks like this:
58          *
59          *      dn: <dn>\n
60          *      [<attr>:[:] <value>\n]
61          *      [<tab><continuedvalue>\n]*
62          *      ...
63          *
64          * If a double colon is used after a type, it means the
65          * following value is encoded as a base 64 string.  This
66          * happens if the value contains a non-printing character
67          * or newline.
68          */
69
70 #ifdef NEW_LOGGING
71         LDAP_LOG( OPERATION, DETAIL1, "str2entry: \"%s\"\n", s ? s : "NULL", 0, 0 );
72 #else
73         Debug( LDAP_DEBUG_TRACE, "=> str2entry\n",
74                 s ? s : "NULL", 0, 0 );
75 #endif
76
77         /* initialize reader/writer lock */
78         e = (Entry *) ch_calloc( 1, sizeof(Entry) );
79
80         if( e == NULL ) {
81 #ifdef NEW_LOGGING
82                 LDAP_LOG( OPERATION, ERR, "str2entry: entry allocation failed.\n", 0, 0, 0 );
83 #else
84                 Debug( LDAP_DEBUG_ANY,
85                     "<= str2entry NULL (entry allocation failed)\n",
86                     0, 0, 0 );
87 #endif
88                 return( NULL );
89         }
90
91         /* initialize entry */
92         e->e_id = NOID;
93
94         /* dn + attributes */
95         vals[1].bv_len = 0;
96         vals[1].bv_val = NULL;
97
98         next = s;
99         while ( (s = ldif_getline( &next )) != NULL ) {
100                 if ( *s == '\n' || *s == '\0' ) {
101                         break;
102                 }
103
104                 if ( ldif_parse_line( s, &type, &vals[0].bv_val, &vals[0].bv_len ) != 0 ) {
105 #ifdef NEW_LOGGING
106                         LDAP_LOG( OPERATION, DETAIL1, "str2entry:  NULL (parse_line)\n",0, 0, 0 );
107 #else
108                         Debug( LDAP_DEBUG_TRACE,
109                             "<= str2entry NULL (parse_line)\n", 0, 0, 0 );
110 #endif
111                         continue;
112                 }
113
114                 if ( strcasecmp( type, "dn" ) == 0 ) {
115                         free( type );
116
117                         if ( e->e_dn != NULL ) {
118 #ifdef NEW_LOGGING
119                                 LDAP_LOG( OPERATION, DETAIL1, "str2entry: "
120                                         "entry %ld has multiple DNs \"%s\" and \"%s\"\n",
121                                         (long) e->e_id, e->e_dn, vals[0].bv_val );
122 #else
123                                 Debug( LDAP_DEBUG_ANY, "str2entry: "
124                                         "entry %ld has multiple DNs \"%s\" and \"%s\"\n",
125                                     (long) e->e_id, e->e_dn, vals[0].bv_val );
126 #endif
127                                 free( vals[0].bv_val );
128                                 entry_free( e );
129                                 return NULL;
130                         }
131
132                         rc = dnPrettyNormal( NULL, &vals[0], &e->e_name, &e->e_nname );
133                         if( rc != LDAP_SUCCESS ) {
134 #ifdef NEW_LOGGING
135                                 LDAP_LOG( OPERATION, DETAIL1, 
136                                         "str2entry: entry %ld has invalid DN \"%s\"\n",
137                                         (long) e->e_id, vals[0].bv_val, 0 );
138 #else
139                                 Debug( LDAP_DEBUG_ANY, "str2entry: "
140                                         "entry %ld has invalid DN \"%s\"\n",
141                                         (long) e->e_id, vals[0].bv_val, 0 );
142 #endif
143                                 entry_free( e );
144                                 free( vals[0].bv_val );
145                                 return NULL;
146                         }
147                         free( vals[0].bv_val );
148                         continue;
149                 }
150
151                 ad = NULL;
152                 rc = slap_str2ad( type, &ad, &text );
153
154                 if( rc != LDAP_SUCCESS ) {
155 #ifdef NEW_LOGGING
156                         LDAP_LOG( OPERATION, DETAIL1, 
157                                 "str2entry:  str2ad(%s): %s\n", type, text, 0 );
158 #else
159                         Debug( slapMode & SLAP_TOOL_MODE
160                                 ? LDAP_DEBUG_ANY : LDAP_DEBUG_TRACE,
161                                 "<= str2entry: str2ad(%s): %s\n", type, text, 0 );
162 #endif
163                         if( slapMode & SLAP_TOOL_MODE ) {
164                                 entry_free( e );
165                                 free( vals[0].bv_val );
166                                 free( type );
167                                 return NULL;
168                         }
169
170                         rc = slap_str2undef_ad( type, &ad, &text );
171                         if( rc != LDAP_SUCCESS ) {
172 #ifdef NEW_LOGGING
173                                 LDAP_LOG( OPERATION, DETAIL1, 
174                                         "str2entry: str2undef_ad(%s): %s\n", type, text, 0 );
175 #else
176                                 Debug( LDAP_DEBUG_ANY,
177                                         "<= str2entry: str2undef_ad(%s): %s\n",
178                                                 type, text, 0 );
179 #endif
180                                 entry_free( e );
181                                 free( vals[0].bv_val );
182                                 free( type );
183                                 return NULL;
184                         }
185                 }
186
187                 if( slapMode & SLAP_TOOL_MODE ) {
188                         struct berval pval;
189                         slap_syntax_validate_func *validate =
190                                 ad->ad_type->sat_syntax->ssyn_validate;
191                         slap_syntax_transform_func *pretty =
192                                 ad->ad_type->sat_syntax->ssyn_pretty;
193
194                         if( pretty ) {
195                                 rc = pretty( ad->ad_type->sat_syntax,
196                                         &vals[0], &pval );
197
198                         } else if( validate ) {
199                                 /*
200                                  * validate value per syntax
201                                  */
202                                 rc = validate( ad->ad_type->sat_syntax, &vals[0] );
203
204                         } else {
205 #ifdef NEW_LOGGING
206                                 LDAP_LOG( OPERATION, INFO, 
207                                         "str2entry: no validator for syntax %s\n", 
208                                         ad->ad_type->sat_syntax->ssyn_oid, 0, 0 );
209 #else
210                                 Debug( LDAP_DEBUG_ANY,
211                                         "str2entry: no validator for syntax %s\n",
212                                         ad->ad_type->sat_syntax->ssyn_oid, 0, 0 );
213 #endif
214                                 entry_free( e );
215                                 free( vals[0].bv_val );
216                                 free( type );
217                                 return NULL;
218                         }
219
220                         if( rc != 0 ) {
221 #ifdef NEW_LOGGING
222                                 LDAP_LOG( OPERATION, ERR, 
223                                         "str2entry:  invalid value for syntax %s\n",
224                                         ad->ad_type->sat_syntax->ssyn_oid, 0, 0 );
225 #else
226                                 Debug( LDAP_DEBUG_ANY,
227                                         "str2entry: invalid value for syntax %s\n",
228                                         ad->ad_type->sat_syntax->ssyn_oid, 0, 0 );
229 #endif
230                                 entry_free( e );
231                                 free( vals[0].bv_val );
232                                 free( type );
233                                 return NULL;
234                         }
235
236                         if( pretty ) {
237                                 free( vals[0].bv_val );
238                                 vals[0] = pval;
239                         }
240                 }
241
242 #ifdef SLAP_NVALUES
243                 nvalsp = NULL;
244                 nvals[0].bv_val = NULL;
245
246 #if 0
247                 if( ad->ad_type->sat_equality &&
248                         ad->ad_type->sat_equality->smr_match &&
249                         ad->ad_type->sat_syntax->ssyn_normalize )
250                 {
251                         rc = ad->ad_type->sat_syntax->ssyn_normalize(
252                                 ad->ad_type->sat_syntax,
253                                 &vals[0], &nvals[0] );
254
255                         if( rc ) {
256 #ifdef NEW_LOGGING
257                                 LDAP_LOG( OPERATION, DETAIL1,
258                                         "str2entry:  NULL (ssyn_normalize %d)\n" , rc, 0, 0 );
259 #else
260                                 Debug( LDAP_DEBUG_ANY,
261                                         "<= str2entry NULL (ssyn_normalize %d)\n", rc, 0, 0 );
262
263                                 entry_free( e );
264                                 free( vals[0].bv_val );
265                                 free( type );
266                                 return NULL;
267                         }
268 #endif
269
270                         nvals[1].bv_len = 0;
271                         nvals[1].bv_val = NULL;
272
273                         nvalsp = &nvals[0];
274                 }
275 #endif
276 #endif
277
278 #ifdef SLAP_NVALUES
279                 rc = attr_merge( e, ad, vals, nvalsp );
280 #else
281                 rc = attr_merge( e, ad, vals );
282 #endif
283                 if( rc != 0 ) {
284 #ifdef NEW_LOGGING
285                         LDAP_LOG( OPERATION, DETAIL1,
286                                 "str2entry:  NULL (attr_merge)\n" , 0, 0, 0 );
287 #else
288                         Debug( LDAP_DEBUG_ANY,
289                             "<= str2entry NULL (attr_merge)\n", 0, 0, 0 );
290 #endif
291                         entry_free( e );
292                         free( vals[0].bv_val );
293                         free( type );
294                         return( NULL );
295                 }
296
297                 free( type );
298                 free( vals[0].bv_val );
299 #ifdef SLAP_NVALUES
300                 free( nvals[0].bv_val );
301 #endif
302         }
303
304         /* check to make sure there was a dn: line */
305         if ( e->e_dn == NULL ) {
306 #ifdef NEW_LOGGING
307                 LDAP_LOG( OPERATION, INFO, 
308                         "str2entry:  entry %ld has no dn.\n", (long) e->e_id, 0, 0 );
309 #else
310                 Debug( LDAP_DEBUG_ANY, "str2entry: entry %ld has no dn\n",
311                     (long) e->e_id, 0, 0 );
312 #endif
313                 entry_free( e );
314                 return NULL;
315         }
316
317 #ifdef NEW_LOGGING
318         LDAP_LOG( OPERATION, DETAIL2,
319                 "str2entry(%s) -> 0x%lx\n", e->e_dn, (unsigned long)e, 0 );
320 #else
321         Debug(LDAP_DEBUG_TRACE, "<= str2entry(%s) -> 0x%lx\n",
322                 e->e_dn, (unsigned long) e, 0 );
323 #endif
324         return( e );
325 }
326
327
328 #define GRABSIZE        BUFSIZ
329
330 #define MAKE_SPACE( n ) { \
331                 while ( ecur + (n) > ebuf + emaxsize ) { \
332                         ptrdiff_t       offset; \
333                         offset = (int) (ecur - ebuf); \
334                         ebuf = (unsigned char *) ch_realloc( (char *) ebuf, \
335                             emaxsize + GRABSIZE ); \
336                         emaxsize += GRABSIZE; \
337                         ecur = ebuf + offset; \
338                 } \
339         }
340
341 char *
342 entry2str(
343     Entry       *e,
344     int         *len )
345 {
346         Attribute       *a;
347         struct berval   *bv;
348         int             i;
349         ber_len_t tmplen;
350
351         assert( e != NULL );
352
353         /*
354          * In string format, an entry looks like this:
355          *      dn: <dn>\n
356          *      [<attr>: <value>\n]*
357          */
358
359         ecur = ebuf;
360
361         /* put the dn */
362         if ( e->e_dn != NULL ) {
363                 /* put "dn: <dn>" */
364                 tmplen = e->e_name.bv_len;
365                 MAKE_SPACE( LDIF_SIZE_NEEDED( 2, tmplen ));
366                 ldif_sput( (char **) &ecur, LDIF_PUT_VALUE, "dn", e->e_dn, tmplen );
367         }
368
369         /* put the attributes */
370         for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
371                 /* put "<type>:[:] <value>" line for each value */
372                 for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) {
373                         bv = &a->a_vals[i];
374                         tmplen = a->a_desc->ad_cname.bv_len;
375                         MAKE_SPACE( LDIF_SIZE_NEEDED( tmplen, bv->bv_len ));
376                         ldif_sput( (char **) &ecur, LDIF_PUT_VALUE,
377                                 a->a_desc->ad_cname.bv_val,
378                             bv->bv_val, bv->bv_len );
379                 }
380         }
381         MAKE_SPACE( 1 );
382         *ecur = '\0';
383         *len = ecur - ebuf;
384
385         return( (char *) ebuf );
386 }
387
388 void
389 entry_free( Entry *e )
390 {
391         /* free an entry structure */
392         assert( e != NULL );
393
394         /* e_private must be freed by the caller */
395         assert( e->e_private == NULL );
396         e->e_private = NULL;
397
398         /* free DNs */
399         if ( e->e_dn != NULL ) {
400                 free( e->e_dn );
401                 e->e_dn = NULL;
402         }
403         if ( e->e_ndn != NULL ) {
404                 free( e->e_ndn );
405                 e->e_ndn = NULL;
406         }
407
408         if ( e->e_bv.bv_val != NULL ) {
409                 free( e->e_bv.bv_val );
410                 e->e_bv.bv_val = NULL;
411         }
412
413         /* free attributes */
414         attrs_free( e->e_attrs );
415         e->e_attrs = NULL;
416
417         free( e );
418 }
419
420 /*
421  * These routines are used only by Backend.
422  *
423  * the Entry has three entry points (ways to find things):
424  *
425  *      by entry        e.g., if you already have an entry from the cache
426  *                      and want to delete it. (really by entry ptr)
427  *      by dn           e.g., when looking for the base object of a search
428  *      by id           e.g., for search candidates
429  *
430  * these correspond to three different avl trees that are maintained.
431  */
432
433 int
434 entry_cmp( Entry *e1, Entry *e2 )
435 {
436         return( e1 < e2 ? -1 : (e1 > e2 ? 1 : 0) );
437 }
438
439 int
440 entry_dn_cmp( const void *v_e1, const void *v_e2 )
441 {
442         /* compare their normalized UPPERCASED dn's */
443         const Entry *e1 = v_e1, *e2 = v_e2;
444         int rc = e1->e_nname.bv_len - e2->e_nname.bv_len;
445         if (rc) return rc;
446         return( strcmp( e1->e_ndn, e2->e_ndn ) );
447 }
448
449 int
450 entry_id_cmp( const void *v_e1, const void *v_e2 )
451 {
452         const Entry *e1 = v_e1, *e2 = v_e2;
453         return( e1->e_id < e2->e_id ? -1 : (e1->e_id > e2->e_id ? 1 : 0) );
454 }
455
456 #ifdef SLAPD_BDB
457
458 /* This is like a ber_len */
459 static ber_len_t
460 entry_lenlen(ber_len_t len)
461 {
462         if (len <= 0x7f)
463                 return 1;
464         if (len <= 0xff)
465                 return 2;
466         if (len <= 0xffff)
467                 return 3;
468         if (len <= 0xffffff)
469                 return 4;
470         return 5;
471 }
472
473 static void
474 entry_putlen(unsigned char **buf, ber_len_t len)
475 {
476         ber_len_t lenlen = entry_lenlen(len);
477
478         if (lenlen == 1) {
479                 **buf = (unsigned char) len;
480         } else {
481                 int i;
482                 **buf = 0x80 | ((unsigned char) lenlen - 1);
483                 for (i=lenlen-1; i>0; i--) {
484                         (*buf)[i] = (unsigned char) len;
485                         len >>= 8;
486                 }
487         }
488         *buf += lenlen;
489 }
490
491 static ber_len_t
492 entry_getlen(unsigned char **buf)
493 {
494         ber_len_t len;
495         int i;
496
497         len = *(*buf)++;
498         if (len <= 0x7f)
499                 return len;
500         i = len & 0x7f;
501         len = 0;
502         for (;i > 0; i--) {
503                 len <<= 8;
504                 len |= *(*buf)++;
505         }
506         return len;
507 }
508
509 /* Flatten an Entry into a buffer. The buffer is filled with just the
510  * strings/bervals of all the entry components. Each field is preceded
511  * by its length, encoded the way ber_put_len works. Every field is NUL
512  * terminated.  The entire buffer size is precomputed so that a single
513  * malloc can be performed. The entry size is also recorded,
514  * to aid in entry_decode.
515  */
516 int entry_encode(Entry *e, struct berval *bv)
517 {
518         ber_len_t siz = sizeof(Entry);
519         ber_len_t len, dnlen, ndnlen;
520         int i;
521         Attribute *a;
522         unsigned char *ptr;
523
524 #ifdef NEW_LOGGING
525         LDAP_LOG( OPERATION, DETAIL1, "entry_encode: id: 0x%08lx  \"%s\"\n",
526                 (long) e->e_id, e->e_dn, 0 );
527 #else
528         Debug( LDAP_DEBUG_TRACE, "=> entry_encode(0x%08lx): %s\n",
529                 (long) e->e_id, e->e_dn, 0 );
530 #endif
531         dnlen = e->e_name.bv_len;
532         ndnlen = e->e_nname.bv_len;
533         len = dnlen + ndnlen + 2;       /* two trailing NUL bytes */
534         len += entry_lenlen(dnlen);
535         len += entry_lenlen(ndnlen);
536         for (a=e->e_attrs; a; a=a->a_next) {
537                 /* For AttributeDesc, we only store the attr name */
538                 siz += sizeof(Attribute);
539                 len += a->a_desc->ad_cname.bv_len+1;
540                 len += entry_lenlen(a->a_desc->ad_cname.bv_len);
541                 for (i=0; a->a_vals[i].bv_val; i++) {
542                         siz += sizeof(struct berval);
543                         len += a->a_vals[i].bv_len + 1;
544                         len += entry_lenlen(a->a_vals[i].bv_len);
545                 }
546                 len += entry_lenlen(i);
547                 siz += sizeof(struct berval);   /* empty berval at end */
548         }
549         len += 1;       /* NUL byte at end */
550         len += entry_lenlen(siz);
551         bv->bv_len = len;
552         bv->bv_val = ch_malloc(len);
553         ptr = (unsigned char *)bv->bv_val;
554         entry_putlen(&ptr, siz);
555         entry_putlen(&ptr, dnlen);
556         AC_MEMCPY(ptr, e->e_dn, dnlen);
557         ptr += dnlen;
558         *ptr++ = '\0';
559         entry_putlen(&ptr, ndnlen);
560         AC_MEMCPY(ptr, e->e_ndn, ndnlen);
561         ptr += ndnlen;
562         *ptr++ = '\0';
563
564         for (a=e->e_attrs; a; a=a->a_next) {
565                 entry_putlen(&ptr, a->a_desc->ad_cname.bv_len);
566                 AC_MEMCPY(ptr, a->a_desc->ad_cname.bv_val,
567                         a->a_desc->ad_cname.bv_len);
568                 ptr += a->a_desc->ad_cname.bv_len;
569                 *ptr++ = '\0';
570                 if (a->a_vals) {
571                     for (i=0; a->a_vals[i].bv_val; i++);
572                     entry_putlen(&ptr, i);
573                     for (i=0; a->a_vals[i].bv_val; i++) {
574                         entry_putlen(&ptr, a->a_vals[i].bv_len);
575                         memcpy(ptr, a->a_vals[i].bv_val,
576                                 a->a_vals[i].bv_len);
577                         ptr += a->a_vals[i].bv_len;
578                         *ptr++ = '\0';
579                     }
580                 }
581         }
582         *ptr = '\0';
583         return 0;
584 }
585
586 /* Retrieve an Entry that was stored using entry_encode above.
587  * We malloc a single block with the size stored above for the Entry
588  * and all if its Attributes. We also must lookup the stored
589  * attribute names to get AttributeDescriptions. To detect if the
590  * attributes of an Entry are later modified, we note that e->e_attr
591  * is always a constant offset from (e).
592  *
593  * Note: everything is stored in a single contiguous block, so
594  * you can not free individual attributes or names from this
595  * structure. Attempting to do so will likely corrupt memory.
596  */
597 int entry_decode(struct berval *bv, Entry **e)
598 {
599         int i, j;
600         int rc;
601         Attribute *a;
602         Entry *x;
603         const char *text;
604         AttributeDescription *ad;
605         unsigned char *ptr = (unsigned char *)bv->bv_val;
606         BerVarray bptr;
607
608         i = entry_getlen(&ptr);
609         x = ch_calloc(1, i);
610         i = entry_getlen(&ptr);
611         x->e_name.bv_val = ptr;
612         x->e_name.bv_len = i;
613         ptr += i+1;
614         i = entry_getlen(&ptr);
615         x->e_nname.bv_val = ptr;
616         x->e_nname.bv_len = i;
617         ptr += i+1;
618 #ifdef NEW_LOGGING
619         LDAP_LOG( OPERATION, DETAIL2, "entry_decode: \"%s\"\n", x->e_dn, 0, 0 );
620 #else
621         Debug( LDAP_DEBUG_TRACE,
622             "entry_decode: \"%s\"\n",
623             x->e_dn, 0, 0 );
624 #endif
625         x->e_bv = *bv;
626
627         /* A valid entry must have at least one attr, so this
628          * pointer can never be NULL
629          */
630         x->e_attrs = (Attribute *)(x+1);
631         bptr = (BerVarray)x->e_attrs;
632         a = NULL;
633
634         while ((i = entry_getlen(&ptr))) {
635                 struct berval bv;
636                 bv.bv_len = i;
637                 bv.bv_val = ptr;
638                 if (a) {
639                         a->a_next = (Attribute *)bptr;
640                 }
641                 a = (Attribute *)bptr;
642                 ad = NULL;
643                 rc = slap_bv2ad( &bv, &ad, &text );
644
645                 if( rc != LDAP_SUCCESS ) {
646 #ifdef NEW_LOGGING
647                         LDAP_LOG( OPERATION, INFO, 
648                                 "entry_decode: str2ad(%s): %s\n", ptr, text, 0 );
649 #else
650                         Debug( LDAP_DEBUG_TRACE,
651                                 "<= entry_decode: str2ad(%s): %s\n", ptr, text, 0 );
652 #endif
653                         rc = slap_bv2undef_ad( &bv, &ad, &text );
654
655                         if( rc != LDAP_SUCCESS ) {
656 #ifdef NEW_LOGGING
657                                 LDAP_LOG( OPERATION, INFO, 
658                                         "entry_decode:  str2undef_ad(%s): %s\n", ptr, text, 0 );
659 #else
660                                 Debug( LDAP_DEBUG_ANY,
661                                         "<= entry_decode: str2undef_ad(%s): %s\n",
662                                                 ptr, text, 0 );
663 #endif
664                                 return rc;
665                         }
666                 }
667                 ptr += i + 1;
668                 a->a_desc = ad;
669                 bptr = (BerVarray)(a+1);
670                 a->a_vals = bptr;
671                 a->a_flags = 0;
672                 j = entry_getlen(&ptr);
673
674                 while (j) {
675                         i = entry_getlen(&ptr);
676                         bptr->bv_len = i;
677                         bptr->bv_val = (char *)ptr;
678                         ptr += i+1;
679                         bptr++;
680                         j--;
681                 }
682                 bptr->bv_val = NULL;
683                 bptr->bv_len = 0;
684                 bptr++;
685         }
686         if (a)
687                 a->a_next = NULL;
688 #ifdef NEW_LOGGING
689         LDAP_LOG( OPERATION, DETAIL1, "entry_decode:  %s\n", x->e_dn, 0, 0 );
690 #else
691         Debug(LDAP_DEBUG_TRACE, "<= entry_decode(%s)\n",
692                 x->e_dn, 0, 0 );
693 #endif
694         *e = x;
695         return 0;
696 }
697 #endif