Minor fix.
[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.8  1998-02-11 11:53:34  adam
8  * Changed code so that it compiles as C++.
9  *
10  * Revision 1.7  1995/09/29 17:12:27  quinn
11  * Smallish
12  *
13  * Revision 1.6  1995/09/27  15:03:00  quinn
14  * Modified function heads & prototypes.
15  *
16  * Revision 1.5  1995/08/10  08:54:47  quinn
17  * Added Explain.
18  *
19  * Revision 1.4  1995/06/16  13:16:12  quinn
20  * Fixed Defaultdiagformat.
21  *
22  * Revision 1.3  1995/05/16  08:51:00  quinn
23  * License, documentation, and memory fixes
24  *
25  * Revision 1.2  1995/02/09  15:51:50  quinn
26  * Works better now.
27  *
28  * Revision 1.1  1995/02/03  17:04:39  quinn
29  * Initial revision
30  *
31  */
32
33 #include <odr.h>
34 #include <odr_use.h>
35
36 int odr_external(ODR o, Odr_external **p, int opt)
37 {
38     Odr_external *pp;
39     static Odr_arm arm[] =
40     {
41         {ODR_EXPLICIT, ODR_CONTEXT, 0, ODR_EXTERNAL_single, (Odr_fun)odr_any},
42         {ODR_IMPLICIT, ODR_CONTEXT, 1, ODR_EXTERNAL_octet, (Odr_fun)odr_octetstring},
43         {ODR_IMPLICIT, ODR_CONTEXT, 2, ODR_EXTERNAL_arbitrary, (Odr_fun)odr_bitstring},
44         {-1, -1, -1, -1, 0}
45     };
46
47     odr_implicit_settag(o, ODR_UNIVERSAL, ODR_EXTERNAL);
48     if (!odr_sequence_begin(o, p, sizeof(Odr_external)))
49         return opt;
50     pp = *p;
51     return
52         odr_oid(o, &pp->direct_reference, 1) &&
53         odr_integer(o, &pp->indirect_reference, 1) &&
54         odr_graphicstring(o, &pp->descriptor, 1) &&
55         odr_choice(o, arm, &pp->u, &pp->which) &&
56         odr_sequence_end(o);
57 }
58
59 int odr_visiblestring(ODR o, char **p, int opt)
60 {
61     return odr_implicit(o, odr_cstring, p, ODR_UNIVERSAL, ODR_VISIBLESTRING,
62         opt);
63 }    
64
65 /*
66  * a char may not be sufficient to hold a general string, but we'll deal
67  * with that once we start looking more closely at UniCode & co.
68  */
69 int odr_generalstring(ODR o, char **p, int opt)
70 {
71     return odr_implicit(o, odr_cstring, p, ODR_UNIVERSAL, ODR_GENERALSTRING,
72         opt);
73 }    
74
75 int odr_graphicstring(ODR o, char **p, int opt)
76 {
77     return odr_implicit(o, odr_cstring, p, ODR_UNIVERSAL, ODR_GRAPHICSTRING,
78         opt);
79 }    
80
81 int odr_generalizedtime(ODR o, char **p, int opt)
82 {
83     return odr_implicit(o, odr_cstring, p, ODR_UNIVERSAL, ODR_GENERALIZEDTIME,
84         opt);
85 }