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