Old versions of GILS tables
[yaz-moved-to-github.git] / odr / odr_tag.c
1 /*
2  * Copyright (c) 1995, Index Data
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: odr_tag.c,v $
7  * Revision 1.8  1997-05-14 06:53:59  adam
8  * C++ support.
9  *
10  * Revision 1.7  1996/02/20 12:52:54  quinn
11  * Added odr_peektag
12  *
13  * Revision 1.6  1995/12/14  16:28:26  quinn
14  * More explain stuff.
15  *
16  * Revision 1.5  1995/09/29  17:12:27  quinn
17  * Smallish
18  *
19  * Revision 1.4  1995/09/27  15:03:00  quinn
20  * Modified function heads & prototypes.
21  *
22  * Revision 1.3  1995/05/16  08:51:00  quinn
23  * License, documentation, and memory fixes
24  *
25  * Revision 1.2  1995/03/08  12:12:31  quinn
26  * Added better error checking.
27  *
28  * Revision 1.1  1995/02/02  16:21:54  quinn
29  * First kick.
30  *
31  */
32
33 #include <odr.h>
34
35 int odr_peektag(ODR o, int *zclass, int *tag, int *cons)
36 {
37     if (o->direction != ODR_DECODE)
38     {
39         o->error = OOTHER;
40         return 0;
41     }
42     if (o->stackp > -1 && !odr_constructed_more(o))
43         return 0;
44     if (ber_dectag(o->bp, zclass, tag, cons) <= 0)
45     {
46         o->error = OREQUIRED;
47         return 0;
48     }
49     return 1;
50 }
51
52 int odr_implicit_settag(ODR o, int zclass, int tag)
53 {
54     if (o->error)
55         return 0;
56     if (o->t_class < 0)
57     {
58         o->t_class = zclass;
59         o->t_tag = tag;
60     }
61     return 1;
62 }
63
64 int odr_initmember(ODR o, void *p, int size)
65 {
66     char **pp = (char **) p;
67
68     if (o->error)
69         return 0;
70     if (o->direction == ODR_DECODE)
71         *pp = odr_malloc(o, size);
72     else if (!*pp)
73     {
74         o->t_class = -1;
75         return 0;
76     }
77     return 1;
78 }