License, documentation, and memory fixes
[yaz-moved-to-github.git] / odr / odr_use.c
1 /*
2  * Copyright (c) 1995, Index Data
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: odr_use.c,v $
7  * Revision 1.3  1995-05-16 08:51:00  quinn
8  * License, documentation, and memory fixes
9  *
10  * Revision 1.2  1995/02/09  15:51:50  quinn
11  * Works better now.
12  *
13  * Revision 1.1  1995/02/03  17:04:39  quinn
14  * Initial revision
15  *
16  */
17
18 #include <odr.h>
19 #include <odr_use.h>
20
21 int odr_external(ODR o, Odr_external **p, int opt)
22 {
23     Odr_external *pp;
24     static Odr_arm arm[] =
25     {
26         {ODR_EXPLICIT, ODR_CONTEXT, 0, ODR_EXTERNAL_single, odr_any},
27         {ODR_IMPLICIT, ODR_CONTEXT, 1, ODR_EXTERNAL_octet, odr_octetstring},
28         {ODR_IMPLICIT, ODR_CONTEXT, 2, ODR_EXTERNAL_arbitrary, odr_bitstring},
29         {-1, -1, -1, -1, 0}
30     };
31
32     odr_implicit_settag(o, ODR_UNIVERSAL, ODR_EXTERNAL);
33     if (!odr_sequence_begin(o, p, sizeof(Odr_external)))
34         return opt;
35     pp = *p;
36     return
37         odr_oid(o, &pp->direct_reference, 1) &&
38         odr_integer(o, &pp->indirect_reference, 1) &&
39         odr_graphicstring(o, &pp->descriptor, 1) &&
40         odr_choice(o, arm, &pp->u, &pp->which) &&
41         odr_sequence_end(o);
42 }
43
44 int odr_visiblestring(ODR o, char **p, int opt)
45 {
46     return odr_implicit(o, odr_cstring, p, ODR_UNIVERSAL, ODR_VISIBLESTRING,
47         opt);
48 }    
49
50 int odr_graphicstring(ODR o, char **p, int opt)
51 {
52     return odr_implicit(o, odr_cstring, p, ODR_UNIVERSAL, ODR_GRAPHICSTRING,
53         opt);
54 }