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