2 * Copyright (c) 1999-2001, Index Data.
3 * See the file LICENSE for details.
6 * Revision 1.1 2003-10-27 12:21:30 adam
7 * Source restructure. yaz-marcdump part of installation
9 * Revision 1.9 2001/03/25 21:55:12 adam
10 * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate.
12 * Revision 1.8 2001/02/21 13:46:53 adam
15 * Revision 1.7 2001/02/20 11:25:32 adam
16 * Added ill_get_APDU and ill_get_Cancel.
18 * Revision 1.6 2000/08/10 08:41:26 adam
21 * Revision 1.5 2000/02/24 08:52:01 adam
24 * Revision 1.4 2000/02/04 11:01:15 adam
25 * Added more elements.
27 * Revision 1.3 2000/01/31 13:15:21 adam
28 * Removed uses of assert(3). Cleanup of ODR. CCL parser update so
29 * that some characters are not surrounded by spaces in resulting term.
32 * Revision 1.2 2000/01/15 09:38:51 adam
33 * Implemented ill_get_ILLRequest. Added some type mappings for ILL protocol.
35 * Revision 1.1 1999/12/16 23:36:19 adam
36 * Implemented ILL protocol. Minor updates ASN.1 compiler.
42 bool_t *ill_get_bool (struct ill_get_ctl *gc, const char *name,
43 const char *sub, int val)
48 bool_t *r = (bool_t *) odr_malloc (o, sizeof(*r));
50 strcpy(element, name);
53 strcat (element, ",");
54 strcat (element, sub);
57 v = (gc->f)(gc->clientData, element);
66 int *ill_get_int (struct ill_get_ctl *gc, const char *name,
67 const char *sub, int val)
73 strcpy(element, name);
76 strcat (element, ",");
77 strcat (element, sub);
79 v = (gc->f)(gc->clientData, element);
82 return odr_intdup(o, val);
85 int *ill_get_enumerated (struct ill_get_ctl *gc, const char *name,
86 const char *sub, int val)
88 return ill_get_int(gc, name, sub, val);
91 ILL_String *ill_get_ILL_String_x (struct ill_get_ctl *gc, const char *name,
92 const char *sub, const char *vdefault)
94 ILL_String *r = (ILL_String *) odr_malloc (gc->odr, sizeof(*r));
98 strcpy(element, name);
101 strcat (element, ",");
102 strcat (element, sub);
104 v = (gc->f)(gc->clientData, element);
109 r->which = ILL_String_GeneralString;
110 r->u.GeneralString = odr_strdup (gc->odr, v);
114 ILL_String *ill_get_ILL_String(struct ill_get_ctl *gc, const char *name,
117 return ill_get_ILL_String_x (gc, name, sub, 0);
120 ILL_ISO_Date *ill_get_ILL_ISO_Date (struct ill_get_ctl *gc, const char *name,
121 const char *sub, const char *val)
126 strcpy(element, name);
129 strcat (element, ",");
130 strcat (element, sub);
132 v = (gc->f)(gc->clientData, element);
137 return odr_strdup (gc->odr, v);
140 ILL_ISO_Time *ill_get_ILL_ISO_Time (struct ill_get_ctl *gc, const char *name,
141 const char *sub, const char *val)
146 strcpy(element, name);
149 strcat (element, ",");
150 strcat (element, sub);
152 v = (gc->f)(gc->clientData, element);
157 return odr_strdup (gc->odr, v);
160 ILL_Person_Or_Institution_Symbol *ill_get_Person_Or_Insitution_Symbol (
161 struct ill_get_ctl *gc, const char *name, const char *sub)
165 ILL_Person_Or_Institution_Symbol *p =
166 (ILL_Person_Or_Institution_Symbol *) odr_malloc (o, sizeof(*p));
168 strcpy(element, name);
171 strcat (element, ",");
172 strcat (element, sub);
174 p->which = ILL_Person_Or_Institution_Symbol_person_symbol;
175 if ((p->u.person_symbol = ill_get_ILL_String (gc, element, "person")))
178 p->which = ILL_Person_Or_Institution_Symbol_institution_symbol;
179 if ((p->u.institution_symbol =
180 ill_get_ILL_String (gc, element, "institution")))
185 static ILL_Name_Of_Person_Or_Institution *ill_get_Name_Of_Person_Or_Institution(
186 struct ill_get_ctl *gc, const char *name, const char *sub)
190 ILL_Name_Of_Person_Or_Institution *p =
191 (ILL_Name_Of_Person_Or_Institution *) odr_malloc (o, sizeof(*p));
193 strcpy(element, name);
196 strcat (element, ",");
197 strcat (element, sub);
199 p->which = ILL_Name_Of_Person_Or_Institution_name_of_person;
200 if ((p->u.name_of_person =
201 ill_get_ILL_String (gc, element, "name-of-person")))
204 p->which = ILL_Name_Of_Person_Or_Institution_name_of_institution;
205 if ((p->u.name_of_institution =
206 ill_get_ILL_String (gc, element, "name-of-institution")))
211 ILL_System_Id *ill_get_System_Id(struct ill_get_ctl *gc,
212 const char *name, const char *sub)
218 strcpy(element, name);
221 strcat (element, ",");
222 strcat (element, sub);
224 p = (ILL_System_Id *) odr_malloc (o, sizeof(*p));
225 p->person_or_institution_symbol = ill_get_Person_Or_Insitution_Symbol (
226 gc, element, "person-or-institution-symbol");
227 p->name_of_person_or_institution = ill_get_Name_Of_Person_Or_Institution (
228 gc, element, "name-of-person-or-institution");
232 ILL_Transaction_Id *ill_get_Transaction_Id (struct ill_get_ctl *gc,
233 const char *name, const char *sub)
236 ILL_Transaction_Id *r = (ILL_Transaction_Id *) odr_malloc (o, sizeof(*r));
239 strcpy(element, name);
242 strcat (element, ",");
243 strcat (element, sub);
245 r->initial_requester_id =
246 ill_get_System_Id (gc, element, "initial-requester-id");
247 r->transaction_group_qualifier =
248 ill_get_ILL_String_x (gc, element, "transaction-group-qualifier", "");
249 r->transaction_qualifier =
250 ill_get_ILL_String_x (gc, element, "transaction-qualifier", "");
251 r->sub_transaction_qualifier =
252 ill_get_ILL_String (gc, element, "sub-transaction-qualifier");
257 ILL_Service_Date_this *ill_get_Service_Date_this (
258 struct ill_get_ctl *gc, const char *name, const char *sub)
261 ILL_Service_Date_this *r =
262 (ILL_Service_Date_this *) odr_malloc (o, sizeof(*r));
265 strcpy(element, name);
268 strcat (element, ",");
269 strcat (element, sub);
271 r->date = ill_get_ILL_ISO_Date (gc, element, "date", "20000101");
272 r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
276 ILL_Service_Date_original *ill_get_Service_Date_original (
277 struct ill_get_ctl *gc, const char *name, const char *sub)
280 ILL_Service_Date_original *r =
281 (ILL_Service_Date_original *) odr_malloc (o, sizeof(*r));
284 strcpy(element, name);
287 strcat (element, ",");
288 strcat (element, sub);
290 r->date = ill_get_ILL_ISO_Date (gc, element, "date", 0);
291 r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
292 if (!r->date && !r->time)
297 ILL_Service_Date_Time *ill_get_Service_Date_Time (
298 struct ill_get_ctl *gc, const char *name, const char *sub)
301 ILL_Service_Date_Time *r =
302 (ILL_Service_Date_Time *) odr_malloc (o, sizeof(*r));
305 strcpy(element, name);
308 strcat (element, ",");
309 strcat (element, sub);
311 r->date_time_of_this_service = ill_get_Service_Date_this (
312 gc, element, "this");
313 r->date_time_of_original_service = ill_get_Service_Date_original (
314 gc, element, "original");
318 ILL_Requester_Optional_Messages_Type *ill_get_Requester_Optional_Messages_Type (
319 struct ill_get_ctl *gc, const char *name, const char *sub)
322 ILL_Requester_Optional_Messages_Type *r =
323 (ILL_Requester_Optional_Messages_Type *) odr_malloc (o, sizeof(*r));
326 strcpy(element, name);
329 strcat (element, ",");
330 strcat (element, sub);
332 r->can_send_RECEIVED = ill_get_bool (gc, element, "can-send-RECEIVED", 0);
333 r->can_send_RETURNED = ill_get_bool (gc, element, "can-send-RETURNED", 0);
334 r->requester_SHIPPED =
335 ill_get_enumerated (gc, element, "requester-SHIPPED", 1);
336 r->requester_CHECKED_IN =
337 ill_get_enumerated (gc, element, "requester-CHECKED-IN", 1);
341 ILL_Item_Id *ill_get_Item_Id (
342 struct ill_get_ctl *gc, const char *name, const char *sub)
345 ILL_Item_Id *r = (ILL_Item_Id *) odr_malloc (o, sizeof(*r));
348 strcpy(element, name);
351 strcat (element, ",");
352 strcat (element, sub);
354 r->item_type = ill_get_enumerated (gc, element, "item-type",
355 ILL_Item_Id_monograph);
356 r->held_medium_type = 0;
357 r->call_number = ill_get_ILL_String(gc, element, "call-number");
358 r->author = ill_get_ILL_String(gc, element, "author");
359 r->title = ill_get_ILL_String(gc, element, "title");
360 r->sub_title = ill_get_ILL_String(gc, element, "sub-title");
361 r->sponsoring_body = ill_get_ILL_String(gc, element, "sponsoring-body");
362 r->place_of_publication =
363 ill_get_ILL_String(gc, element, "place-of-publication");
364 r->publisher = ill_get_ILL_String(gc, element, "publisher");
365 r->series_title_number =
366 ill_get_ILL_String(gc, element, "series-title-number");
367 r->volume_issue = ill_get_ILL_String(gc, element, "volume-issue");
368 r->edition = ill_get_ILL_String(gc, element, "edition");
369 r->publication_date = ill_get_ILL_String(gc, element, "publication-date");
370 r->publication_date_of_component =
371 ill_get_ILL_String(gc, element, "publication-date-of-component");
372 r->author_of_article = ill_get_ILL_String(gc, element,
373 "author-of-article");
374 r->title_of_article = ill_get_ILL_String(gc, element, "title-of-article");
375 r->pagination = ill_get_ILL_String(gc, element, "pagination");
376 r->national_bibliography_no = 0;
377 r->iSBN = ill_get_ILL_String(gc, element, "ISBN");
378 r->iSSN = ill_get_ILL_String(gc, element, "ISSN");
380 r->additional_no_letters =
381 ill_get_ILL_String(gc, element, "additional-no-letters");
382 r->verification_reference_source =
383 ill_get_ILL_String(gc, element, "verification-reference-source");
388 ILL_Client_Id *ill_get_Client_Id (
389 struct ill_get_ctl *gc, const char *name, const char *sub)
393 ILL_Client_Id *r = (ILL_Client_Id *) odr_malloc(o, sizeof(*r));
395 strcpy(element, name);
398 strcat (element, ",");
399 strcat (element, sub);
401 r->client_name = ill_get_ILL_String (gc, element, "client-name");
402 r->client_status = ill_get_ILL_String (gc, element, "client-status");
403 r->client_identifier = ill_get_ILL_String (gc, element,
404 "client-identifier");
408 ILL_Postal_Address *ill_get_Postal_Address (
409 struct ill_get_ctl *gc, const char *name, const char *sub)
412 ILL_Postal_Address *r =
413 (ILL_Postal_Address *) odr_malloc(o, sizeof(*r));
416 strcpy(element, name);
419 strcat (element, ",");
420 strcat (element, sub);
422 r->name_of_person_or_institution =
423 ill_get_Name_Of_Person_Or_Institution (
424 gc, element, "name-of-person-or-institution");
425 r->extended_postal_delivery_address =
427 gc, element, "extended-postal-delivery-address");
428 r->street_and_number =
429 ill_get_ILL_String (gc, element, "street-and-number");
431 ill_get_ILL_String (gc, element, "post-office-box");
432 r->city = ill_get_ILL_String (gc, element, "city");
433 r->region = ill_get_ILL_String (gc, element, "region");
434 r->country = ill_get_ILL_String (gc, element, "country");
435 r->postal_code = ill_get_ILL_String (gc, element, "postal-code");
439 ILL_System_Address *ill_get_System_Address (
440 struct ill_get_ctl *gc, const char *name, const char *sub)
443 ILL_System_Address *r =
444 (ILL_System_Address *) odr_malloc(o, sizeof(*r));
447 strcpy(element, name);
450 strcat (element, ",");
451 strcat (element, sub);
453 r->telecom_service_identifier =
454 ill_get_ILL_String (gc, element, "telecom-service-identifier");
455 r->telecom_service_address =
456 ill_get_ILL_String (gc, element, "telecom-service-addreess");
460 ILL_Delivery_Address *ill_get_Delivery_Address (
461 struct ill_get_ctl *gc, const char *name, const char *sub)
464 ILL_Delivery_Address *r =
465 (ILL_Delivery_Address *) odr_malloc(o, sizeof(*r));
468 strcpy(element, name);
471 strcat (element, ",");
472 strcat (element, sub);
475 ill_get_Postal_Address (gc, element, "postal-address");
476 r->electronic_address =
477 ill_get_System_Address (gc, element, "electronic-address");
481 ILL_Search_Type *ill_get_Search_Type (
482 struct ill_get_ctl *gc, const char *name, const char *sub)
485 ILL_Search_Type *r = (ILL_Search_Type *) odr_malloc(o, sizeof(*r));
488 strcpy(element, name);
491 strcat (element, ",");
492 strcat (element, sub);
494 r->level_of_service = ill_get_ILL_String (gc, element, "level-of-service");
495 r->need_before_date = ill_get_ILL_ISO_Date (gc, element,
496 "need-before-date", 0);
497 r->expiry_date = ill_get_ILL_ISO_Date (gc, element, "expiry-date", 0);
498 r->expiry_flag = ill_get_enumerated (gc, element, "expiry-flag", 3);
503 ILL_Request *ill_get_ILLRequest (
504 struct ill_get_ctl *gc, const char *name, const char *sub)
507 ILL_Request *r = (ILL_Request *) odr_malloc(o, sizeof(*r));
510 strcpy(element, name);
513 strcat (element, ",");
514 strcat (element, sub);
516 r->protocol_version_num =
517 ill_get_enumerated (gc, element, "protocol-version-num",
518 ILL_Request_version_2);
520 r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
521 r->service_date_time =
522 ill_get_Service_Date_Time (gc, element, "service-date-time");
523 r->requester_id = ill_get_System_Id (gc, element, "requester-id");
524 r->responder_id = ill_get_System_Id (gc, element, "responder-id");
525 r->transaction_type =
526 ill_get_enumerated(gc, element, "transaction-type", 1);
528 r->delivery_address =
529 ill_get_Delivery_Address (gc, element, "delivery-address");
530 r->delivery_service = 0; /* TODO */
531 /* ill_get_Delivery_Service (gc, element, "delivery-service"); */
533 ill_get_Delivery_Address (gc, element, "billing-address");
535 r->num_iLL_service_type = 1;
536 r->iLL_service_type = (ILL_Service_Type **)
537 odr_malloc (o, sizeof(*r->iLL_service_type));
538 *r->iLL_service_type =
539 ill_get_enumerated (gc, element, "ill-service-type",
540 ILL_Service_Type_copy_non_returnable);
542 r->responder_specific_service = 0;
543 r->requester_optional_messages =
544 ill_get_Requester_Optional_Messages_Type (
545 gc, element,"requester-optional-messages");
546 r->search_type = ill_get_Search_Type(gc, element, "search-type");
547 r->num_supply_medium_info_type = 0;
548 r->supply_medium_info_type = 0;
550 r->place_on_hold = ill_get_enumerated (
551 gc, element, "place-on-hold",
552 ILL_Place_On_Hold_Type_according_to_responder_policy);
553 r->client_id = ill_get_Client_Id (gc, element, "client-id");
555 r->item_id = ill_get_Item_Id (gc, element, "item-id");
556 r->supplemental_item_description = 0;
557 r->cost_info_type = 0;
558 r->copyright_compliance =
559 ill_get_ILL_String(gc, element, "copyright-complicance");
560 r->third_party_info_type = 0;
561 r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0);
562 r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0);
563 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
564 r->forward_note = ill_get_ILL_String(gc, element, "forward-note");
565 r->num_iLL_request_extensions = 0;
566 r->iLL_request_extensions = 0;
570 ILL_ItemRequest *ill_get_ItemRequest (
571 struct ill_get_ctl *gc, const char *name, const char *sub)
574 ILL_ItemRequest *r = (ILL_ItemRequest *)odr_malloc(o, sizeof(*r));
577 strcpy(element, name);
580 strcat (element, ",");
581 strcat (element, sub);
583 r->protocol_version_num =
584 ill_get_enumerated (gc, element, "protocol-version-num",
585 ILL_Request_version_2);
587 r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
588 r->service_date_time =
589 ill_get_Service_Date_Time (gc, element, "service-date-time");
590 r->requester_id = ill_get_System_Id (gc, element, "requester-id");
591 r->responder_id = ill_get_System_Id (gc, element, "responder-id");
592 r->transaction_type =
593 ill_get_enumerated(gc, element, "transaction-type", 1);
595 r->delivery_address =
596 ill_get_Delivery_Address (gc, element, "delivery-address");
597 r->delivery_service = 0; /* TODO */
598 /* ill_get_Delivery_Service (gc, element, "delivery-service"); */
600 ill_get_Delivery_Address (gc, element, "billing-address");
602 r->num_iLL_service_type = 1;
603 r->iLL_service_type = (ILL_Service_Type **)
604 odr_malloc (o, sizeof(*r->iLL_service_type));
605 *r->iLL_service_type =
606 ill_get_enumerated (gc, element, "ill-service-type",
607 ILL_Service_Type_copy_non_returnable);
609 r->responder_specific_service = 0;
610 r->requester_optional_messages =
611 ill_get_Requester_Optional_Messages_Type (
612 gc, element,"requester-optional-messages");
613 r->search_type = ill_get_Search_Type(gc, element, "search-type");
614 r->num_supply_medium_info_type = 0;
615 r->supply_medium_info_type = 0;
617 r->place_on_hold = ill_get_enumerated (
618 gc, element, "place-on-hold",
619 ILL_Place_On_Hold_Type_according_to_responder_policy);
620 r->client_id = ill_get_Client_Id (gc, element, "client-id");
622 r->item_id = ill_get_Item_Id (gc, element, "item-id");
623 r->supplemental_item_description = 0;
624 r->cost_info_type = 0;
625 r->copyright_compliance =
626 ill_get_ILL_String(gc, element, "copyright-complicance");
627 r->third_party_info_type = 0;
628 r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0);
629 r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0);
630 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
631 r->forward_note = ill_get_ILL_String(gc, element, "forward-note");
632 r->num_iLL_request_extensions = 0;
633 r->iLL_request_extensions = 0;
637 ILL_Cancel *ill_get_Cancel (
638 struct ill_get_ctl *gc, const char *name, const char *sub)
641 ILL_Cancel *r = (ILL_Cancel *)odr_malloc(o, sizeof(*r));
644 strcpy(element, name);
647 strcat (element, ",");
648 strcat (element, sub);
650 r->protocol_version_num =
651 ill_get_enumerated (gc, element, "protocol-version-num",
652 ILL_Request_version_2);
654 r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
655 r->service_date_time =
656 ill_get_Service_Date_Time (gc, element, "service-date-time");
657 r->requester_id = ill_get_System_Id (gc, element, "requester-id");
658 r->responder_id = ill_get_System_Id (gc, element, "responder-id");
659 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
661 r->num_cancel_extensions = 0;
662 r->cancel_extensions = 0;
666 ILL_APDU *ill_get_APDU (
667 struct ill_get_ctl *gc, const char *name, const char *sub)
670 ILL_APDU *r = (ILL_APDU *)odr_malloc(o, sizeof(*r));
674 strcpy (element, name);
675 strcat (element, ",which");
677 v = (gc->f)(gc->clientData, element);
680 if (!strcmp (v, "request"))
682 r->which = ILL_APDU_ILL_Request;
683 r->u.illRequest = ill_get_ILLRequest(gc, name, sub);
685 else if (!strcmp (v, "cancel"))
687 r->which = ILL_APDU_Cancel;
688 r->u.Cancel = ill_get_Cancel(gc, name, sub);