Check for config.h (currently not generated).
[yaz-moved-to-github.git] / odr / odr_use.c
1 /*
2  * Copyright (c) 1995-2000, Index Data
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: odr_use.c,v $
7  * Revision 1.11  2000-02-29 13:44:55  adam
8  * Check for config.h (currently not generated).
9  *
10  * Revision 1.10  1999/11/30 13:47:12  adam
11  * Improved installation. Moved header files to include/yaz.
12  *
13  * Revision 1.9  1999/04/20 09:56:48  adam
14  * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
15  * Modified all encoders/decoders to reflect this change.
16  *
17  * Revision 1.8  1998/02/11 11:53:34  adam
18  * Changed code so that it compiles as C++.
19  *
20  * Revision 1.7  1995/09/29 17:12:27  quinn
21  * Smallish
22  *
23  * Revision 1.6  1995/09/27  15:03:00  quinn
24  * Modified function heads & prototypes.
25  *
26  * Revision 1.5  1995/08/10  08:54:47  quinn
27  * Added Explain.
28  *
29  * Revision 1.4  1995/06/16  13:16:12  quinn
30  * Fixed Defaultdiagformat.
31  *
32  * Revision 1.3  1995/05/16  08:51:00  quinn
33  * License, documentation, and memory fixes
34  *
35  * Revision 1.2  1995/02/09  15:51:50  quinn
36  * Works better now.
37  *
38  * Revision 1.1  1995/02/03  17:04:39  quinn
39  * Initial revision
40  *
41  */
42 #if HAVE_CONFIG_H
43 #include <config.h>
44 #endif
45
46 #include <yaz/odr.h>
47
48 int odr_external(ODR o, Odr_external **p, int opt, const char *name)
49 {
50     Odr_external *pp;
51     static Odr_arm arm[] =
52     {
53         {ODR_EXPLICIT, ODR_CONTEXT, 0, ODR_EXTERNAL_single, 
54          (Odr_fun)odr_any, "single"},
55         {ODR_IMPLICIT, ODR_CONTEXT, 1, ODR_EXTERNAL_octet,
56          (Odr_fun)odr_octetstring, "octet"},
57         {ODR_IMPLICIT, ODR_CONTEXT, 2, ODR_EXTERNAL_arbitrary,
58          (Odr_fun)odr_bitstring, "arbitrary"},
59         {-1, -1, -1, -1, 0, 0}
60     };
61
62     odr_implicit_settag(o, ODR_UNIVERSAL, ODR_EXTERNAL);
63     if (!odr_sequence_begin(o, p, sizeof(Odr_external), name))
64         return opt;
65     pp = *p;
66     return
67         odr_oid(o, &pp->direct_reference, 1, "direct") &&
68         odr_integer(o, &pp->indirect_reference, 1, "indirect") &&
69         odr_graphicstring(o, &pp->descriptor, 1, "descriptor") &&
70         odr_choice(o, arm, &pp->u, &pp->which, 0) &&
71         odr_sequence_end(o);
72 }
73
74 int odr_visiblestring(ODR o, char **p, int opt, const char *name)
75 {
76     return odr_implicit_tag(o, odr_cstring, p, ODR_UNIVERSAL,
77                             ODR_VISIBLESTRING, opt, name);
78 }    
79
80 /*
81  * a char may not be sufficient to hold a general string, but we'll deal
82  * with that once we start looking more closely at UniCode & co.
83  */
84 int odr_generalstring(ODR o, char **p, int opt, const char *name)
85 {
86     return odr_implicit_tag(o, odr_cstring, p, ODR_UNIVERSAL,
87                             ODR_GENERALSTRING,opt, name);
88 }    
89
90 int odr_graphicstring(ODR o, char **p, int opt, const char *name)
91 {
92     return odr_implicit_tag(o, odr_cstring, p, ODR_UNIVERSAL,
93                         ODR_GRAPHICSTRING, opt, name);
94 }    
95
96 int odr_generalizedtime(ODR o, char **p, int opt, const char *name)
97 {
98     return odr_implicit_tag(o, odr_cstring, p, ODR_UNIVERSAL,
99                             ODR_GENERALIZEDTIME, opt, name);
100 }