1 | /*
|
---|
2 | * Copyright (c) 1995-1999, 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:09:46 johnmcp
|
---|
8 | * Added the YAZ toolkit source to the packages directory (for z39.50 stuff)
|
---|
9 | *
|
---|
10 | * Revision 1.9 1999/11/30 13:47:11 adam
|
---|
11 | * Improved installation. Moved header files to include/yaz.
|
---|
12 | *
|
---|
13 | * Revision 1.8 1999/04/20 09:56:47 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.7 1998/02/11 11:53:32 adam
|
---|
18 | * Changed code so that it compiles as C++.
|
---|
19 | *
|
---|
20 | * Revision 1.6 1998/01/05 09:04:57 adam
|
---|
21 | * Fixed bugs in encoders/decoders - Not operator (!) missing.
|
---|
22 | *
|
---|
23 | * Revision 1.5 1995/09/29 17:11:53 quinn
|
---|
24 | * Smallish
|
---|
25 | *
|
---|
26 | * Revision 1.4 1995/09/27 15:02:41 quinn
|
---|
27 | * Modified function heads & prototypes.
|
---|
28 | *
|
---|
29 | * Revision 1.3 1995/08/15 11:59:41 quinn
|
---|
30 | * Updated External
|
---|
31 | *
|
---|
32 | * Revision 1.2 1995/06/05 10:52:05 quinn
|
---|
33 | * Fixed some negligences.
|
---|
34 | *
|
---|
35 | * Revision 1.1 1995/06/02 09:49:15 quinn
|
---|
36 | * Adding access control
|
---|
37 | *
|
---|
38 | *
|
---|
39 | */
|
---|
40 |
|
---|
41 | #include <yaz/proto.h>
|
---|
42 |
|
---|
43 | int z_Encryption1(ODR o, Z_Encryption1 **p, int opt, const char *name)
|
---|
44 | {
|
---|
45 | if (!odr_sequence_begin(o, p, sizeof(**p), 0))
|
---|
46 | return opt && odr_ok(o);
|
---|
47 | return
|
---|
48 | odr_implicit(o, odr_octetstring, &(*p)->cryptType,
|
---|
49 | ODR_CONTEXT, 1, 1) &&
|
---|
50 | odr_implicit(o, odr_octetstring, &(*p)->credential,
|
---|
51 | ODR_CONTEXT, 2, 1) &&
|
---|
52 | odr_implicit(o, odr_octetstring, &(*p)->data, ODR_CONTEXT, 3, 0) &&
|
---|
53 | odr_sequence_end(o);
|
---|
54 | }
|
---|
55 |
|
---|
56 | int z_EnumeratedPrompt1(ODR o, Z_EnumeratedPrompt1 **p, int opt,
|
---|
57 | const char *name)
|
---|
58 | {
|
---|
59 | if (!odr_sequence_begin(o, p, sizeof(**p), 0))
|
---|
60 | return opt && odr_ok(o);
|
---|
61 | return
|
---|
62 | odr_implicit(o, odr_integer, &(*p)->type, ODR_CONTEXT, 1, 0) &&
|
---|
63 | odr_implicit(o, odr_visiblestring, &(*p)->suggestedString, ODR_CONTEXT,
|
---|
64 | 2, 1) &&
|
---|
65 | odr_sequence_end(o);
|
---|
66 | }
|
---|
67 |
|
---|
68 | int z_PromptId1(ODR o, Z_PromptId1 **p, int opt, const char *name)
|
---|
69 | {
|
---|
70 | static Odr_arm arm[] =
|
---|
71 | {
|
---|
72 | {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_PromptId1_enumeratedPrompt,
|
---|
73 | (Odr_fun)z_EnumeratedPrompt1, 0},
|
---|
74 | {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_PromptId1_nonEnumeratedPrompt,
|
---|
75 | odr_visiblestring, 0},
|
---|
76 | {-1, -1, -1, -1, 0, 0}
|
---|
77 | };
|
---|
78 |
|
---|
79 | if (o->direction == ODR_DECODE)
|
---|
80 | *p = (Z_PromptId1 *)odr_malloc(o, sizeof(**p));
|
---|
81 | else if (!*p)
|
---|
82 | return opt;
|
---|
83 | if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
|
---|
84 | return 1;
|
---|
85 | *p = 0;
|
---|
86 | return opt && odr_ok(o);
|
---|
87 | }
|
---|
88 |
|
---|
89 | int z_PromptInfo1(ODR o, Z_PromptInfo1 **p, int opt, const char *name)
|
---|
90 | {
|
---|
91 | static Odr_arm arm[] =
|
---|
92 | {
|
---|
93 | {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Challenge1_character,
|
---|
94 | odr_visiblestring, 0},
|
---|
95 | {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Challenge1_encrypted,
|
---|
96 | (Odr_fun)z_Encryption1, 0},
|
---|
97 | {-1, -1, -1, -1, 0, 0}
|
---|
98 | };
|
---|
99 |
|
---|
100 | if (o->direction == ODR_DECODE)
|
---|
101 | *p = (Z_PromptInfo1 *)odr_malloc(o, sizeof(**p));
|
---|
102 | else if (!*p)
|
---|
103 | return opt;
|
---|
104 | if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
|
---|
105 | return 1;
|
---|
106 | *p = 0;
|
---|
107 | return opt && odr_ok(o);
|
---|
108 | }
|
---|
109 |
|
---|
110 | int z_ChallengeUnit1(ODR o, Z_ChallengeUnit1 **p, int opt, const char *name)
|
---|
111 | {
|
---|
112 | if (!odr_sequence_begin(o, p, sizeof(**p), 0))
|
---|
113 | return opt && odr_ok(o);
|
---|
114 | return
|
---|
115 | odr_explicit(o, z_PromptId1, &(*p)->promptId, ODR_CONTEXT, 1, 0) &&
|
---|
116 | odr_implicit(o, odr_visiblestring, &(*p)->defaultResponse,
|
---|
117 | ODR_CONTEXT, 2, 1) &&
|
---|
118 | odr_explicit(o, z_PromptInfo1, &(*p)->promptInfo,
|
---|
119 | ODR_CONTEXT, 3, 1) &&
|
---|
120 | odr_implicit(o, odr_visiblestring, &(*p)->regExpr,
|
---|
121 | ODR_CONTEXT, 4, 1) &&
|
---|
122 | odr_implicit(o, odr_null, &(*p)->responseRequired,
|
---|
123 | ODR_CONTEXT, 5, 1) &&
|
---|
124 | odr_implicit_settag(o, ODR_CONTEXT, 6) &&
|
---|
125 | (odr_sequence_of(o, odr_visiblestring, &(*p)->allowedValues,
|
---|
126 | &(*p)->num_values, 0) || odr_ok(o)) &&
|
---|
127 | odr_implicit(o, odr_null, &(*p)->shouldSave, ODR_CONTEXT, 7, 1) &&
|
---|
128 | odr_implicit(o, odr_integer, &(*p)->dataType, ODR_CONTEXT, 8, 1) &&
|
---|
129 | odr_implicit(o, z_External, &(*p)->diagnostic, ODR_CONTEXT, 9, 1) &&
|
---|
130 | odr_sequence_end(o);
|
---|
131 | }
|
---|
132 |
|
---|
133 | int z_Challenge1(ODR o, Z_Challenge1 **p, int opt, const char *name)
|
---|
134 | {
|
---|
135 | if (o->direction == ODR_ENCODE)
|
---|
136 | *p = (Z_Challenge1 *)odr_malloc(o, sizeof(**p));
|
---|
137 | else if (!*p)
|
---|
138 | return opt;
|
---|
139 | if (odr_sequence_of(o, (Odr_fun)z_ChallengeUnit1, &(*p)->list,
|
---|
140 | &(*p)->num_challenges, 0))
|
---|
141 | return 1;
|
---|
142 | *p = 0;
|
---|
143 | return opt && odr_ok(o);
|
---|
144 | }
|
---|
145 |
|
---|
146 | int z_ResponseUnit1(ODR o, Z_ResponseUnit1 **p, int opt, const char *name)
|
---|
147 | {
|
---|
148 | static Odr_arm arm[] =
|
---|
149 | {
|
---|
150 | {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_Response1_string,
|
---|
151 | odr_visiblestring, 0},
|
---|
152 | {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_Response1_accept,
|
---|
153 | (Odr_fun)odr_bool, 0},
|
---|
154 | {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_Response1_acknowledge,
|
---|
155 | (Odr_fun)odr_null, 0},
|
---|
156 | {ODR_EXPLICIT, ODR_CONTEXT, 4, Z_Response1_diagnostic,
|
---|
157 | (Odr_fun)z_DiagRec, 0},
|
---|
158 | {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_Response1_encrypted,
|
---|
159 | (Odr_fun)z_Encryption1, 0},
|
---|
160 | {-1, -1, -1, -1, 0, 0}
|
---|
161 | };
|
---|
162 |
|
---|
163 | if (!odr_sequence_begin(o, p, sizeof(**p), 0))
|
---|
164 | return opt && odr_ok(o);
|
---|
165 | return
|
---|
166 | odr_explicit(o, z_PromptId1, &(*p)->promptId, ODR_CONTEXT, 1, 0) &&
|
---|
167 | odr_constructed_begin(o, p, ODR_CONTEXT, 2, 0) &&
|
---|
168 | odr_choice(o, arm, &(*p)->u, &(*p)->which, 0) &&
|
---|
169 | odr_constructed_end(o) &&
|
---|
170 | odr_sequence_end(o);
|
---|
171 | }
|
---|
172 |
|
---|
173 | int z_Response1(ODR o, Z_Response1 **p, int opt, const char *name)
|
---|
174 | {
|
---|
175 | if (o->direction == ODR_ENCODE)
|
---|
176 | *p = (Z_Response1 *)odr_malloc(o, sizeof(**p));
|
---|
177 | else if (!*p)
|
---|
178 | return opt;
|
---|
179 | if (odr_sequence_of(o, (Odr_fun)z_ResponseUnit1, &(*p)->list,
|
---|
180 | &(*p)->num_responses, 0))
|
---|
181 | return 1;
|
---|
182 | *p = 0;
|
---|
183 | return opt && odr_ok(o);
|
---|
184 | }
|
---|
185 |
|
---|
186 | int z_PromptObject1(ODR o, Z_PromptObject1 **p, int opt, const char *name)
|
---|
187 | {
|
---|
188 | static Odr_arm arm[] =
|
---|
189 | {
|
---|
190 | {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_PromptObject1_challenge,
|
---|
191 | (Odr_fun)z_Challenge1, 0},
|
---|
192 | {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_PromptObject1_response,
|
---|
193 | (Odr_fun)z_Response1, 0},
|
---|
194 | {-1, -1, -1, -1, 0, 0}
|
---|
195 | };
|
---|
196 |
|
---|
197 | if (o->direction == ODR_DECODE)
|
---|
198 | *p = (Z_PromptObject1 *)odr_malloc(o, sizeof(**p));
|
---|
199 | else if (!*p)
|
---|
200 | return opt;
|
---|
201 | if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
|
---|
202 | return 1;
|
---|
203 | *p = 0;
|
---|
204 | return opt && odr_ok(o);
|
---|
205 | }
|
---|