Added body-of-text to BIB-1 ANY and the WAIS profile
[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.7  1996-02-20 12:52:54  quinn
8  * Added odr_peektag
9  *
10  * Revision 1.6  1995/12/14  16:28:26  quinn
11  * More explain stuff.
12  *
13  * Revision 1.5  1995/09/29  17:12:27  quinn
14  * Smallish
15  *
16  * Revision 1.4  1995/09/27  15:03:00  quinn
17  * Modified function heads & prototypes.
18  *
19  * Revision 1.3  1995/05/16  08:51:00  quinn
20  * License, documentation, and memory fixes
21  *
22  * Revision 1.2  1995/03/08  12:12:31  quinn
23  * Added better error checking.
24  *
25  * Revision 1.1  1995/02/02  16:21:54  quinn
26  * First kick.
27  *
28  */
29
30 #include <odr.h>
31
32 int odr_peektag(ODR o, int *class, int *tag, int *cons)
33 {
34     if (o->direction != ODR_DECODE)
35     {
36         o->error = OOTHER;
37         return 0;
38     }
39     if (o->stackp > -1 && !odr_constructed_more(o))
40         return 0;
41     if (ber_dectag(o->bp, class, tag, cons) <= 0)
42     {
43         o->error = OREQUIRED;
44         return 0;
45     }
46     return 1;
47 }
48
49 int odr_implicit_settag(ODR o, int class, int tag)
50 {
51     if (o->error)
52         return 0;
53     if (o->t_class < 0)
54     {
55         o->t_class = class;
56         o->t_tag = tag;
57     }
58     return 1;
59 }
60
61 int odr_initmember(ODR o, void *p, int size)
62 {
63     char **pp = (char **) p;
64
65     if (o->error)
66         return 0;
67     if (o->direction == ODR_DECODE)
68         *pp = odr_malloc(o, size);
69     else if (!*pp)
70     {
71         o->t_class = -1;
72         return 0;
73     }
74     return 1;
75 }