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