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