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