Fix URL of SRU diagnostics list.
[yaz-moved-to-github.git] / src / odr_tag.c
1 /*
2  * Copyright (C) 1995-2005, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: odr_tag.c,v 1.5 2005-08-11 14:21:55 adam Exp $
6  */
7 /**
8  * \file odr_tag.c
9  * \brief Implements ODR IMPLICIT tagging codec
10  */
11 #if HAVE_CONFIG_H
12 #include <config.h>
13 #endif
14
15 #include "odr-priv.h"
16
17 int odr_peektag(ODR o, int *zclass, int *tag, int *cons)
18 {
19     if (o->direction != ODR_DECODE)
20     {
21         odr_seterror(o, OOTHER, 48);
22         return 0;
23     }
24     if (ODR_STACK_NOT_EMPTY(o) && !odr_constructed_more(o))
25         return 0;
26     if (ber_dectag(o->bp, zclass, tag, cons, odr_max(o)) <= 0)
27     {
28         odr_seterror(o, OREQUIRED, 49);
29         return 0;
30     }
31     return 1;
32 }
33
34 int odr_implicit_settag(ODR o, int zclass, int tag)
35 {
36     if (o->error)
37         return 0;
38     if (o->t_class < 0)
39     {
40         o->t_class = zclass;
41         o->t_tag = tag;
42     }
43     return 1;
44 }
45
46 int odr_initmember(ODR o, void *p, int size)
47 {
48     char **pp = (char **) p;
49
50     if (o->error)
51         return 0;
52     if (o->direction == ODR_DECODE)
53         *pp = (char *)odr_malloc(o, size);
54     else if (!*pp)
55     {
56         o->t_class = -1;
57         return 0;
58     }
59     return 1;
60 }
61 /*
62  * Local variables:
63  * c-basic-offset: 4
64  * indent-tabs-mode: nil
65  * End:
66  * vim: shiftwidth=4 tabstop=8 expandtab
67  */
68