Fix mistake: fuzzy matching is 5=103, not 5=102
[yaz-moved-to-github.git] / src / odr_bit.c
1 /*
2  * Copyright (C) 1995-2005, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: odr_bit.c,v 1.5 2005-06-25 15:46:04 adam Exp $
6  */
7
8 /**
9  * \file odr_bit.c
10  * \brief Implements ODR BITSTRING codec
11  */
12
13 #if HAVE_CONFIG_H
14 #include <config.h>
15 #endif
16
17 #include <string.h>
18 #include "odr-priv.h"
19
20 /*
21  * Top level bitstring string en/decoder.
22  * Returns 1 on success, 0 on error.
23  */
24 int odr_bitstring(ODR o, Odr_bitmask **p, int opt, const char *name)
25 {
26     int res, cons = 0;
27
28     if (o->error)
29         return 0;
30     if (o->t_class < 0)
31     {
32         o->t_class = ODR_UNIVERSAL;
33         o->t_tag = ODR_BITSTRING;
34     }
35     if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
36         return 0;
37     if (!res)
38         return odr_missing(o, opt, name);
39     if (o->direction == ODR_PRINT)
40     {
41         odr_prname(o, name);
42         odr_printf(o, "BITSTRING(len=%d)\n",(*p)->top + 1);
43         return 1;
44     }
45     if (o->direction == ODR_DECODE)
46     {
47         *p = (Odr_bitmask *)odr_malloc(o, sizeof(Odr_bitmask));
48         memset((*p)->bits, 0, ODR_BITMASK_SIZE);
49         (*p)->top = -1;
50     }
51 #if 0
52     /* ignoring the cons helps with at least one target. 
53      * http://bugzilla.indexdata.dk/cgi-bin/bugzilla/show_bug.cgi?id=24
54      */
55     return ber_bitstring(o, *p, 0);
56 #else
57     return ber_bitstring(o, *p, cons);
58 #endif
59 }
60 /*
61  * Local variables:
62  * c-basic-offset: 4
63  * indent-tabs-mode: nil
64  * End:
65  * vim: shiftwidth=4 tabstop=8 expandtab
66  */
67