Updated information about YAZ.
[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.10  1999-11-30 13:47:11  adam
8  * Improved installation. Moved header files to include/yaz.
9  *
10  * Revision 1.9  1998/02/11 11:53:34  adam
11  * Changed code so that it compiles as C++.
12  *
13  * Revision 1.8  1997/05/14 06:53:59  adam
14  * C++ support.
15  *
16  * Revision 1.7  1996/02/20 12:52:54  quinn
17  * Added odr_peektag
18  *
19  * Revision 1.6  1995/12/14  16:28:26  quinn
20  * More explain stuff.
21  *
22  * Revision 1.5  1995/09/29  17:12:27  quinn
23  * Smallish
24  *
25  * Revision 1.4  1995/09/27  15:03:00  quinn
26  * Modified function heads & prototypes.
27  *
28  * Revision 1.3  1995/05/16  08:51:00  quinn
29  * License, documentation, and memory fixes
30  *
31  * Revision 1.2  1995/03/08  12:12:31  quinn
32  * Added better error checking.
33  *
34  * Revision 1.1  1995/02/02  16:21:54  quinn
35  * First kick.
36  *
37  */
38
39 #include <yaz/odr.h>
40
41 int odr_peektag(ODR o, int *zclass, int *tag, int *cons)
42 {
43     if (o->direction != ODR_DECODE)
44     {
45         o->error = OOTHER;
46         return 0;
47     }
48     if (o->stackp > -1 && !odr_constructed_more(o))
49         return 0;
50     if (ber_dectag(o->bp, zclass, tag, cons) <= 0)
51     {
52         o->error = OREQUIRED;
53         return 0;
54     }
55     return 1;
56 }
57
58 int odr_implicit_settag(ODR o, int zclass, int tag)
59 {
60     if (o->error)
61         return 0;
62     if (o->t_class < 0)
63     {
64         o->t_class = zclass;
65         o->t_tag = tag;
66     }
67     return 1;
68 }
69
70 int odr_initmember(ODR o, void *p, int size)
71 {
72     char **pp = (char **) p;
73
74     if (o->error)
75         return 0;
76     if (o->direction == ODR_DECODE)
77         *pp = (char *)odr_malloc(o, size);
78     else if (!*pp)
79     {
80         o->t_class = -1;
81         return 0;
82     }
83     return 1;
84 }