source: trunk/gsdl/packages/yaz/asn/prt-exd.c@ 1343

Last change on this file since 1343 was 1343, checked in by johnmcp, 24 years ago

Added the YAZ toolkit source to the packages directory (for z39.50 stuff)

  • Property svn:keywords set to Author Date Id Revision
File size: 13.6 KB
Line 
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:50 johnmcp
8 * Added the YAZ toolkit source to the packages directory (for z39.50 stuff)
9 *
10 * Revision 1.11 1999/11/30 13:47:11 adam
11 * Improved installation. Moved header files to include/yaz.
12 *
13 * Revision 1.10 1999/05/26 13:49:12 adam
14 * DB Update implemented in client (very basic).
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:32 adam
21 * Changed code so that it compiles as C++.
22 *
23 * Revision 1.7 1998/02/10 15:31:46 adam
24 * Implemented date and time structure. Changed the Update Extended
25 * Service.
26 *
27 * Revision 1.6 1998/01/05 09:04:57 adam
28 * Fixed bugs in encoders/decoders - Not operator (!) missing.
29 *
30 * Revision 1.5 1997/04/30 08:52:02 quinn
31 * Null
32 *
33 * Revision 1.4 1996/10/10 12:35:12 quinn
34 * Added Update extended service.
35 *
36 * Revision 1.3 1995/09/29 17:11:54 quinn
37 * Smallish
38 *
39 * Revision 1.2 1995/09/27 15:02:41 quinn
40 * Modified function heads & prototypes.
41 *
42 * Revision 1.1 1995/08/21 09:16:32 quinn
43 * Added Extended services + Item Order
44 *
45 *
46 */
47
48#include <yaz/proto.h>
49
50int z_TaskPackage(ODR o, Z_TaskPackage **p, int opt, const char *name)
51{
52 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
53 return opt && odr_ok(o);
54 return
55 odr_implicit(o, odr_oid, &(*p)->packageType, ODR_CONTEXT, 1, 0) &&
56 odr_implicit(o, z_InternationalString, &(*p)->packageName,
57 ODR_CONTEXT, 2, 1) &&
58 odr_implicit(o, z_InternationalString, &(*p)->userId,
59 ODR_CONTEXT, 3, 1) &&
60 odr_implicit(o, z_IntUnit, &(*p)->retentionTime, ODR_CONTEXT, 4, 1) &&
61 odr_implicit(o, z_Permissions, &(*p)->permissions,
62 ODR_CONTEXT, 5, 1) &&
63 odr_implicit(o, z_InternationalString, &(*p)->description,
64 ODR_CONTEXT, 6, 1) &&
65 odr_implicit(o, odr_octetstring, &(*p)->targetReference,
66 ODR_CONTEXT, 7, 0) &&
67 odr_implicit(o, odr_generalizedtime, &(*p)->creationDateTime,
68 ODR_CONTEXT, 8, 1) &&
69 odr_implicit(o, odr_integer, &(*p)->taskStatus,
70 ODR_CONTEXT, 9, 0) &&
71 odr_implicit_settag(o, ODR_CONTEXT, 10) &&
72 (odr_sequence_of(o, (Odr_fun)z_DiagRec, &(*p)->packageDiagnostics,
73 &(*p)->num_packageDiagnostics, 0) || odr_ok(o)) &&
74 odr_implicit(o, z_External, &(*p)->taskSpecificParameters,
75 ODR_CONTEXT, 11, 0) &&
76 odr_sequence_end(o);
77}
78
79/* ----------------------- ITEM ORDER --------------------- */
80
81int z_IOTargetPart(ODR o, Z_IOTargetPart **p, int opt, const char *name)
82{
83 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
84 return opt && odr_ok(o);
85 return
86 odr_implicit(o, z_External, &(*p)->itemRequest, ODR_CONTEXT, 1, 1) &&
87 odr_implicit(o, z_External, &(*p)->statusOrErrorReport, ODR_CONTEXT,
88 2, 0) &&
89 odr_implicit(o, odr_integer, &(*p)->auxiliaryStatus, ODR_CONTEXT,
90 3, 1) &&
91 odr_sequence_end(o);
92}
93
94int z_IOResultSetItem(ODR o, Z_IOResultSetItem **p, int opt, const char *name)
95{
96 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
97 return opt && odr_ok(o);
98 return
99 odr_implicit(o, z_InternationalString, &(*p)->resultSetId, ODR_CONTEXT,
100 1, 0) &&
101 odr_implicit(o, odr_integer, &(*p)->item, ODR_CONTEXT, 2, 1) &&
102 odr_sequence_end(o);
103}
104
105int z_IOOriginPartNotToKeep(ODR o, Z_IOOriginPartNotToKeep **p, int opt,
106 const char *name)
107{
108 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
109 return opt && odr_ok(o);
110 return
111 odr_implicit(o, z_IOResultSetItem, &(*p)->resultSetItem, ODR_CONTEXT,
112 1, 0) &&
113 odr_implicit(o, z_External, &(*p)->itemRequest, ODR_CONTEXT, 2, 1) &&
114 odr_sequence_end(o);
115}
116
117int z_IOContact(ODR o, Z_IOContact **p, int opt, const char *name)
118{
119 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
120 return opt && odr_ok(o);
121 return
122 odr_implicit(o, z_InternationalString, &(*p)->name, ODR_CONTEXT,
123 1, 1) &&
124 odr_implicit(o, z_InternationalString, &(*p)->phone, ODR_CONTEXT,
125 2, 1) &&
126 odr_implicit(o, z_InternationalString, &(*p)->email, ODR_CONTEXT,
127 3, 1) &&
128 odr_sequence_end(o);
129}
130
131int z_IOCreditCardInfo(ODR o, Z_IOCreditCardInfo **p, int opt,
132 const char *name)
133{
134 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
135 return opt && odr_ok(o);
136 return
137 odr_implicit(o, z_InternationalString, &(*p)->nameOnCard, ODR_CONTEXT,
138 1, 0) &&
139 odr_implicit(o, z_InternationalString, &(*p)->expirationDate,
140 ODR_CONTEXT, 2, 0) &&
141 odr_implicit(o, z_InternationalString, &(*p)->cardNumber, ODR_CONTEXT,
142 3, 0) &&
143 odr_sequence_end(o);
144}
145
146int z_IOBilling(ODR o, Z_IOBilling **p, int opt, const char *name)
147{
148 static Odr_arm arm[] =
149 {
150 {ODR_IMPLICIT, ODR_CONTEXT, 0, Z_IOBilling_billInvoice,
151 (Odr_fun)odr_null, 0},
152 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_IOBilling_prepay,
153 (Odr_fun)odr_null, 0},
154 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_IOBilling_depositAccount,
155 (Odr_fun)odr_null, 0},
156 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_IOBilling_creditCard,
157 (Odr_fun)z_IOCreditCardInfo, 0},
158 {ODR_IMPLICIT, ODR_CONTEXT, 4, Z_IOBilling_cardInfoPreviouslySupplied,
159 (Odr_fun)odr_null, 0},
160 {ODR_IMPLICIT, ODR_CONTEXT, 5, Z_IOBilling_privateKnown,
161 (Odr_fun)odr_null, 0},
162 {ODR_IMPLICIT, ODR_CONTEXT, 6, Z_IOBilling_privateNotKnown,
163 (Odr_fun)z_External, 0},
164 {-1, -1, -1, -1, 0, 0}
165 };
166
167 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
168 return opt && odr_ok(o);
169 return
170 odr_constructed_begin(o, &(*p)->paymentMethod,
171 ODR_CONTEXT, 1, 0) &&
172 odr_choice(o, arm, &(*p)->paymentMethod, &(*p)->which, 0) &&
173 odr_constructed_end(o) &&
174 odr_implicit(o, z_InternationalString, &(*p)->customerReference,
175 ODR_CONTEXT, 2, 1) &&
176 odr_implicit(o, z_InternationalString, &(*p)->customerPONumber,
177 ODR_CONTEXT, 3, 1) &&
178 odr_sequence_end(o);
179}
180
181int z_IOOriginPartToKeep(ODR o, Z_IOOriginPartToKeep **p, int opt,
182 const char *name)
183{
184 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
185 return opt && odr_ok(o);
186 return
187 odr_implicit(o, z_External, &(*p)->supplDescription,
188 ODR_CONTEXT, 1, 1) &&
189 odr_implicit(o, z_IOContact, &(*p)->contact, ODR_CONTEXT, 2, 1) &&
190 odr_implicit(o, z_IOBilling, &(*p)->addlBilling,
191 ODR_CONTEXT, 3, 1) &&
192 odr_sequence_end(o);
193}
194
195int z_IORequest(ODR o, Z_IORequest **p, int opt, const char *name)
196{
197 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
198 return opt && odr_ok(o);
199 return
200 odr_implicit(o, z_IOOriginPartToKeep, &(*p)->toKeep,
201 ODR_CONTEXT, 1, 1) &&
202 odr_implicit(o, z_IOOriginPartNotToKeep, &(*p)->notToKeep,
203 ODR_CONTEXT, 2, 0) &&
204 odr_sequence_end(o);
205}
206
207int z_IOTaskPackage(ODR o, Z_IOTaskPackage **p, int opt, const char *name)
208{
209 if (!odr_sequence_begin(o, p, sizeof(**p), 0))
210 return opt && odr_ok(o);
211 return
212 odr_implicit(o, z_IOOriginPartToKeep, &(*p)->originPart,
213 ODR_CONTEXT, 1, 1) &&
214 odr_implicit(o, z_IOTargetPart, &(*p)->targetPart,
215 ODR_CONTEXT, 2, 0) &&
216 odr_sequence_end(o);
217}
218
219int z_ItemOrder(ODR o, Z_ItemOrder **p, int opt, const char *name)
220{
221 static Odr_arm arm[] =
222 {
223 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_ItemOrder_esRequest,
224 (Odr_fun)z_IORequest, 0},
225 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_ItemOrder_taskPackage,
226 (Odr_fun)z_IOTaskPackage, 0},
227 {-1, -1, -1, -1, 0, 0}
228 };
229
230 if (o->direction == ODR_DECODE)
231 *p = (Z_ItemOrder *)odr_malloc(o, sizeof(**p));
232 else if (!*p)
233 return opt;
234 if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
235 return 1;
236 *p = 0;
237 return opt && odr_ok(o);
238}
239
240/* ----------------------- ITEM UPDATE -------------------- */
241
242int z_IUSuppliedRecordsId (ODR o, Z_IUSuppliedRecordsId **p, int opt,
243 const char *name)
244{
245 static Odr_arm arm[] = {
246 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_IUSuppliedRecordsId_timeStamp,
247 odr_generalizedtime, 0},
248 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_IUSuppliedRecordsId_versionNumber,
249 z_InternationalString, 0},
250 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_IUSuppliedRecordsId_previousVersion,
251 (Odr_fun)odr_external, 0},
252 {-1, -1, -1, -1, 0, 0}
253 };
254 if (!odr_initmember(o, p, sizeof(**p)))
255 return opt && odr_ok(o);
256 if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
257 return 1;
258 *p = 0;
259 return opt && odr_ok(o);
260}
261
262int z_IUCorrelationInfo (ODR o, Z_IUCorrelationInfo **p, int opt,
263 const char *name)
264{
265 if (!odr_sequence_begin (o, p, sizeof(**p), 0))
266 return opt && odr_ok (o);
267 return
268 odr_implicit (o, z_InternationalString,
269 &(*p)->note, ODR_CONTEXT, 1, 1) &&
270 odr_implicit (o, odr_integer,
271 &(*p)->id, ODR_CONTEXT, 2, 1) &&
272 odr_sequence_end (o);
273}
274
275int z_IUSuppliedRecords_elem (ODR o, Z_IUSuppliedRecords_elem **p, int opt,
276 const char *name)
277{
278 static Odr_arm arm[] = {
279 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_IUSuppliedRecords_number,
280 (Odr_fun)odr_integer, 0},
281 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_IUSuppliedRecords_string,
282 (Odr_fun)z_InternationalString, 0},
283 {ODR_IMPLICIT, ODR_CONTEXT, 3, Z_IUSuppliedRecords_opaque,
284 (Odr_fun)odr_octetstring, 0},
285 {-1, -1, -1, -1, 0, 0}
286 };
287 if (!odr_sequence_begin (o, p, sizeof(**p), 0))
288 return opt && odr_ok (o);
289 return
290 ((odr_constructed_begin (o, &(*p)->u, ODR_CONTEXT, 1, 0) &&
291 odr_choice (o, arm, &(*p)->u, &(*p)->which, 0) &&
292 odr_constructed_end (o)) || odr_ok(o)) &&
293 odr_explicit (o, z_IUSuppliedRecordsId,
294 &(*p)->supplementalId, ODR_CONTEXT, 2, 1) &&
295 odr_implicit (o, z_IUCorrelationInfo,
296 &(*p)->correlationInfo, ODR_CONTEXT, 3, 1) &&
297 odr_implicit (o, z_External,
298 &(*p)->record, ODR_CONTEXT, 4, 0) &&
299 odr_sequence_end (o);
300}
301
302int z_IUSuppliedRecords (ODR o, Z_IUSuppliedRecords **p, int opt,
303 const char *name)
304{
305 if (!odr_initmember (o, p, sizeof(**p)))
306 return opt && odr_ok(o);
307 if (odr_sequence_of (o, (Odr_fun)z_IUSuppliedRecords_elem, &(*p)->elements,
308 &(*p)->num, 0))
309 return 1;
310 *p = 0;
311 return opt && odr_ok(o);
312}
313
314int z_IUTaskPackageRecordStructure (ODR o, Z_IUTaskPackageRecordStructure **p,
315 int opt, const char *name)
316{
317 static Odr_arm arm[] = {
318 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_IUTaskPackageRecordStructure_record,
319 (Odr_fun)odr_external, 0},
320 {ODR_EXPLICIT, ODR_CONTEXT, 2,
321 Z_IUTaskPackageRecordStructure_surrogateDiagnostics,
322 (Odr_fun)z_DiagRecs, 0},
323 {-1, -1, -1, -1, 0, 0}
324 };
325 if (!odr_sequence_begin (o, p, sizeof(**p), 0))
326 return opt && odr_ok (o);
327 return
328 ((odr_constructed_begin (o, &(*p)->u, ODR_CONTEXT, 1, 0) &&
329 odr_choice (o, arm, &(*p)->u, &(*p)->which, 0) &&
330 odr_constructed_end (o)) || odr_ok(o)) &&
331 odr_implicit (o, z_IUCorrelationInfo,
332 &(*p)->correlationInfo, ODR_CONTEXT, 2, 1) &&
333 odr_implicit (o, odr_integer,
334 &(*p)->recordStatus, ODR_CONTEXT, 3, 0) &&
335 odr_implicit (o, z_DiagRecs,
336 &(*p)->supplementalDiagnostics, ODR_CONTEXT, 4, 1) &&
337 odr_sequence_end (o);
338}
339
340int z_IUOriginPartToKeep (ODR o, Z_IUOriginPartToKeep **p, int opt,
341 const char *name)
342{
343 if (!odr_sequence_begin (o, p, sizeof(**p), 0))
344 return opt && odr_ok (o);
345 return
346 odr_implicit (o, odr_integer,
347 &(*p)->action, ODR_CONTEXT, 1, 0) &&
348 odr_implicit (o, z_InternationalString,
349 &(*p)->databaseName, ODR_CONTEXT, 2, 0) &&
350 odr_implicit (o, odr_oid,
351 &(*p)->schema, ODR_CONTEXT, 3, 1) &&
352 odr_implicit (o, z_InternationalString,
353 &(*p)->elementSetName, ODR_CONTEXT, 4, 1) &&
354 odr_implicit (o, odr_external,
355 &(*p)->actionQualifier, ODR_CONTEXT, 5, 1) &&
356 odr_sequence_end (o);
357}
358
359int z_IUTargetPart (ODR o, Z_IUTargetPart **p, int opt, const char *name)
360{
361 if (!odr_sequence_begin (o, p, sizeof(**p), 0))
362 return opt && odr_ok (o);
363 return
364 odr_implicit (o, odr_integer,
365 &(*p)->updateStatus, ODR_CONTEXT, 1, 0) &&
366 odr_implicit_settag (o, ODR_CONTEXT, 2) &&
367 (odr_sequence_of(o, (Odr_fun)z_DiagRec, &(*p)->globalDiagnostics,
368 &(*p)->num_globalDiagnostics, 0) || odr_ok(o)) &&
369 odr_implicit_settag (o, ODR_CONTEXT, 3) &&
370 odr_sequence_of(o, (Odr_fun)z_IUTaskPackageRecordStructure,
371 &(*p)->taskPackageRecords,
372 &(*p)->num_taskPackageRecords, 0) &&
373 odr_sequence_end (o);
374}
375
376int z_IUUpdateEsRequest (ODR o, Z_IUUpdateEsRequest **p, int opt,
377 const char *name)
378{
379 if (!odr_sequence_begin (o, p, sizeof(**p), 0))
380 return opt && odr_ok (o);
381 return
382 odr_explicit (o, z_IUOriginPartToKeep,
383 &(*p)->toKeep, ODR_CONTEXT, 1, 0) &&
384 odr_explicit (o, z_IUSuppliedRecords,
385 &(*p)->notToKeep, ODR_CONTEXT, 2, 0) &&
386 odr_sequence_end (o);
387}
388
389int z_IUUpdateTaskPackage (ODR o, Z_IUUpdateTaskPackage **p, int opt,
390 const char *name)
391{
392 if (!odr_sequence_begin (o, p, sizeof(**p), 0))
393 return opt && odr_ok (o);
394 return
395 odr_explicit (o, z_IUOriginPartToKeep,
396 &(*p)->originPart, ODR_CONTEXT, 1, 0) &&
397 odr_explicit (o, z_IUTargetPart,
398 &(*p)->targetPart, ODR_CONTEXT, 2, 0) &&
399 odr_sequence_end (o);
400}
401
402int z_IUUpdate (ODR o, Z_IUUpdate **p, int opt, const char *name)
403{
404 static Odr_arm arm[] = {
405 {ODR_IMPLICIT, ODR_CONTEXT, 1, Z_IUUpdate_esRequest,
406 (Odr_fun)z_IUUpdateEsRequest, 0},
407 {ODR_IMPLICIT, ODR_CONTEXT, 2, Z_IUUpdate_taskPackage,
408 (Odr_fun)z_IUUpdateTaskPackage, 0},
409 {-1, -1, -1, -1, 0, 0}
410 };
411 if (!odr_initmember(o, p, sizeof(**p)))
412 return opt && odr_ok(o);
413 if (odr_choice(o, arm, &(*p)->u, &(*p)->which, 0))
414 return 1;
415 *p = 0;
416 return opt && odr_ok(o);
417}
Note: See TracBrowser for help on using the repository browser.