2 * Copyright (c) 1999-2001, Index Data.
3 * See the file LICENSE for details.
6 * Revision 1.7 2001-02-20 11:25:32 adam
7 * Added ill_get_APDU and ill_get_Cancel.
9 * Revision 1.6 2000/08/10 08:41:26 adam
12 * Revision 1.5 2000/02/24 08:52:01 adam
15 * Revision 1.4 2000/02/04 11:01:15 adam
16 * Added more elements.
18 * Revision 1.3 2000/01/31 13:15:21 adam
19 * Removed uses of assert(3). Cleanup of ODR. CCL parser update so
20 * that some characters are not surrounded by spaces in resulting term.
23 * Revision 1.2 2000/01/15 09:38:51 adam
24 * Implemented ill_get_ILLRequest. Added some type mappings for ILL protocol.
26 * Revision 1.1 1999/12/16 23:36:19 adam
27 * Implemented ILL protocol. Minor updates ASN.1 compiler.
33 bool_t *ill_get_bool (struct ill_get_ctl *gc, const char *name,
34 const char *sub, int val)
39 bool_t *r = odr_malloc (o, sizeof(*r));
41 strcpy(element, name);
44 strcat (element, ",");
45 strcat (element, sub);
48 v = (gc->f)(gc->clientData, element);
57 int *ill_get_int (struct ill_get_ctl *gc, const char *name,
58 const char *sub, int val)
63 int *r = odr_malloc (o, sizeof(*r));
65 strcpy(element, name);
68 strcat (element, ",");
69 strcat (element, sub);
71 v = (gc->f)(gc->clientData, element);
78 int *ill_get_enumerated (struct ill_get_ctl *gc, const char *name,
79 const char *sub, int val)
81 return ill_get_int(gc, name, sub, val);
84 ILL_String *ill_get_ILL_String_x (struct ill_get_ctl *gc, const char *name,
85 const char *sub, const char *vdefault)
87 ILL_String *r = (ILL_String *) odr_malloc (gc->odr, sizeof(*r));
91 strcpy(element, name);
94 strcat (element, ",");
95 strcat (element, sub);
97 v = (gc->f)(gc->clientData, element);
102 r->which = ILL_String_GeneralString;
103 r->u.GeneralString = odr_strdup (gc->odr, v);
107 ILL_String *ill_get_ILL_String(struct ill_get_ctl *gc, const char *name,
110 return ill_get_ILL_String_x (gc, name, sub, 0);
113 ILL_ISO_Date *ill_get_ILL_ISO_Date (struct ill_get_ctl *gc, const char *name,
114 const char *sub, const char *val)
119 strcpy(element, name);
122 strcat (element, ",");
123 strcat (element, sub);
125 v = (gc->f)(gc->clientData, element);
130 return odr_strdup (gc->odr, v);
133 ILL_ISO_Time *ill_get_ILL_ISO_Time (struct ill_get_ctl *gc, const char *name,
134 const char *sub, const char *val)
139 strcpy(element, name);
142 strcat (element, ",");
143 strcat (element, sub);
145 v = (gc->f)(gc->clientData, element);
150 return odr_strdup (gc->odr, v);
153 ILL_Person_Or_Institution_Symbol *ill_get_Person_Or_Insitution_Symbol (
154 struct ill_get_ctl *gc, const char *name, const char *sub)
158 ILL_Person_Or_Institution_Symbol *p = odr_malloc (o, sizeof(*p));
160 strcpy(element, name);
163 strcat (element, ",");
164 strcat (element, sub);
166 p->which = ILL_Person_Or_Institution_Symbol_person_symbol;
167 if ((p->u.person_symbol = ill_get_ILL_String (gc, element, "person")))
170 p->which = ILL_Person_Or_Institution_Symbol_institution_symbol;
171 if ((p->u.institution_symbol =
172 ill_get_ILL_String (gc, element, "institution")))
177 static ILL_Name_Of_Person_Or_Institution *ill_get_Name_Of_Person_Or_Institution(
178 struct ill_get_ctl *gc, const char *name, const char *sub)
182 ILL_Name_Of_Person_Or_Institution *p = odr_malloc (o, sizeof(*p));
184 strcpy(element, name);
187 strcat (element, ",");
188 strcat (element, sub);
190 p->which = ILL_Name_Of_Person_Or_Institution_name_of_person;
191 if ((p->u.name_of_person =
192 ill_get_ILL_String (gc, element, "name-of-person")))
195 p->which = ILL_Name_Of_Person_Or_Institution_name_of_institution;
196 if ((p->u.name_of_institution =
197 ill_get_ILL_String (gc, element, "name-of-institution")))
202 ILL_System_Id *ill_get_System_Id(struct ill_get_ctl *gc,
203 const char *name, const char *sub)
209 strcpy(element, name);
212 strcat (element, ",");
213 strcat (element, sub);
215 p = (ILL_System_Id *) odr_malloc (o, sizeof(*p));
216 p->person_or_institution_symbol = ill_get_Person_Or_Insitution_Symbol (
217 gc, element, "person-or-institution-symbol");
218 p->name_of_person_or_institution = ill_get_Name_Of_Person_Or_Institution (
219 gc, element, "name-of-person-or-institution");
223 ILL_Transaction_Id *ill_get_Transaction_Id (struct ill_get_ctl *gc,
224 const char *name, const char *sub)
227 ILL_Transaction_Id *r = (ILL_Transaction_Id *) odr_malloc (o, sizeof(*r));
230 strcpy(element, name);
233 strcat (element, ",");
234 strcat (element, sub);
236 r->initial_requester_id =
237 ill_get_System_Id (gc, element, "initial-requester-id");
238 r->transaction_group_qualifier =
239 ill_get_ILL_String_x (gc, element, "transaction-group-qualifier", "");
240 r->transaction_qualifier =
241 ill_get_ILL_String_x (gc, element, "transaction-qualifier", "");
242 r->sub_transaction_qualifier =
243 ill_get_ILL_String (gc, element, "sub-transaction-qualifier");
248 ILL_Service_Date_this *ill_get_Service_Date_this (
249 struct ill_get_ctl *gc, const char *name, const char *sub)
252 ILL_Service_Date_this *r =
253 (ILL_Service_Date_this *) odr_malloc (o, sizeof(*r));
256 strcpy(element, name);
259 strcat (element, ",");
260 strcat (element, sub);
262 r->date = ill_get_ILL_ISO_Date (gc, element, "date", "20000101");
263 r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
267 ILL_Service_Date_original *ill_get_Service_Date_original (
268 struct ill_get_ctl *gc, const char *name, const char *sub)
271 ILL_Service_Date_original *r =
272 (ILL_Service_Date_original *) odr_malloc (o, sizeof(*r));
275 strcpy(element, name);
278 strcat (element, ",");
279 strcat (element, sub);
281 r->date = ill_get_ILL_ISO_Date (gc, element, "date", 0);
282 r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
283 if (!r->date && !r->time)
288 ILL_Service_Date_Time *ill_get_Service_Date_Time (
289 struct ill_get_ctl *gc, const char *name, const char *sub)
292 ILL_Service_Date_Time *r =
293 (ILL_Service_Date_Time *) odr_malloc (o, sizeof(*r));
296 strcpy(element, name);
299 strcat (element, ",");
300 strcat (element, sub);
302 r->date_time_of_this_service = ill_get_Service_Date_this (
303 gc, element, "this");
304 r->date_time_of_original_service = ill_get_Service_Date_original (
305 gc, element, "original");
309 ILL_Requester_Optional_Messages_Type *ill_get_Requester_Optional_Messages_Type (
310 struct ill_get_ctl *gc, const char *name, const char *sub)
313 ILL_Requester_Optional_Messages_Type *r =
314 (ILL_Requester_Optional_Messages_Type *) odr_malloc (o, sizeof(*r));
317 strcpy(element, name);
320 strcat (element, ",");
321 strcat (element, sub);
323 r->can_send_RECEIVED = ill_get_bool (gc, element, "can-send-RECEIVED", 0);
324 r->can_send_RETURNED = ill_get_bool (gc, element, "can-send-RETURNED", 0);
325 r->requester_SHIPPED =
326 ill_get_enumerated (gc, element, "requester-SHIPPED", 1);
327 r->requester_CHECKED_IN =
328 ill_get_enumerated (gc, element, "requester-CHECKED-IN", 1);
332 ILL_Item_Id *ill_get_Item_Id (
333 struct ill_get_ctl *gc, const char *name, const char *sub)
336 ILL_Item_Id *r = (ILL_Item_Id *) odr_malloc (o, sizeof(*r));
339 strcpy(element, name);
342 strcat (element, ",");
343 strcat (element, sub);
345 r->item_type = ill_get_enumerated (gc, element, "item-type",
346 ILL_Item_Id_monograph);
347 r->held_medium_type = 0;
348 r->call_number = ill_get_ILL_String(gc, element, "call-number");
349 r->author = ill_get_ILL_String(gc, element, "author");
350 r->title = ill_get_ILL_String(gc, element, "title");
351 r->sub_title = ill_get_ILL_String(gc, element, "sub-title");
352 r->sponsoring_body = ill_get_ILL_String(gc, element, "sponsoring-body");
353 r->place_of_publication =
354 ill_get_ILL_String(gc, element, "place-of-publication");
355 r->publisher = ill_get_ILL_String(gc, element, "publisher");
356 r->series_title_number =
357 ill_get_ILL_String(gc, element, "series-title-number");
358 r->volume_issue = ill_get_ILL_String(gc, element, "volume-issue");
359 r->edition = ill_get_ILL_String(gc, element, "edition");
360 r->publication_date = ill_get_ILL_String(gc, element, "publication-date");
361 r->publication_date_of_component =
362 ill_get_ILL_String(gc, element, "publication-date-of-component");
363 r->author_of_article = ill_get_ILL_String(gc, element,
364 "author-of-article");
365 r->title_of_article = ill_get_ILL_String(gc, element, "title-of-article");
366 r->pagination = ill_get_ILL_String(gc, element, "pagination");
367 r->national_bibliography_no = 0;
368 r->iSBN = ill_get_ILL_String(gc, element, "ISBN");
369 r->iSSN = ill_get_ILL_String(gc, element, "ISSN");
371 r->additional_no_letters =
372 ill_get_ILL_String(gc, element, "additional-no-letters");
373 r->verification_reference_source =
374 ill_get_ILL_String(gc, element, "verification-reference-source");
379 ILL_Client_Id *ill_get_Client_Id (
380 struct ill_get_ctl *gc, const char *name, const char *sub)
384 ILL_Client_Id *r = (ILL_Client_Id *) odr_malloc(o, sizeof(*r));
386 strcpy(element, name);
389 strcat (element, ",");
390 strcat (element, sub);
392 r->client_name = ill_get_ILL_String (gc, element, "client-name");
393 r->client_status = ill_get_ILL_String (gc, element, "client-status");
394 r->client_identifier = ill_get_ILL_String (gc, element,
395 "client-identifier");
399 ILL_Postal_Address *ill_get_Postal_Address (
400 struct ill_get_ctl *gc, const char *name, const char *sub)
403 ILL_Postal_Address *r =
404 (ILL_Postal_Address *) odr_malloc(o, sizeof(*r));
407 strcpy(element, name);
410 strcat (element, ",");
411 strcat (element, sub);
413 r->name_of_person_or_institution =
414 ill_get_Name_Of_Person_Or_Institution (
415 gc, element, "name-of-person-or-institution");
416 r->extended_postal_delivery_address =
418 gc, element, "extended-postal-delivery-address");
419 r->street_and_number =
420 ill_get_ILL_String (gc, element, "street-and-number");
422 ill_get_ILL_String (gc, element, "post-office-box");
423 r->city = ill_get_ILL_String (gc, element, "city");
424 r->region = ill_get_ILL_String (gc, element, "region");
425 r->country = ill_get_ILL_String (gc, element, "country");
426 r->postal_code = ill_get_ILL_String (gc, element, "postal-code");
430 ILL_System_Address *ill_get_System_Address (
431 struct ill_get_ctl *gc, const char *name, const char *sub)
434 ILL_System_Address *r =
435 (ILL_System_Address *) odr_malloc(o, sizeof(*r));
438 strcpy(element, name);
441 strcat (element, ",");
442 strcat (element, sub);
444 r->telecom_service_identifier =
445 ill_get_ILL_String (gc, element, "telecom-service-identifier");
446 r->telecom_service_address =
447 ill_get_ILL_String (gc, element, "telecom-service-addreess");
451 ILL_Delivery_Address *ill_get_Delivery_Address (
452 struct ill_get_ctl *gc, const char *name, const char *sub)
455 ILL_Delivery_Address *r =
456 (ILL_Delivery_Address *) odr_malloc(o, sizeof(*r));
459 strcpy(element, name);
462 strcat (element, ",");
463 strcat (element, sub);
466 ill_get_Postal_Address (gc, element, "postal-address");
467 r->electronic_address =
468 ill_get_System_Address (gc, element, "electronic-address");
472 ILL_Search_Type *ill_get_Search_Type (
473 struct ill_get_ctl *gc, const char *name, const char *sub)
476 ILL_Search_Type *r = (ILL_Search_Type *) odr_malloc(o, sizeof(*r));
479 strcpy(element, name);
482 strcat (element, ",");
483 strcat (element, sub);
485 r->level_of_service = ill_get_ILL_String (gc, element, "level-of-service");
486 r->need_before_date = ill_get_ILL_ISO_Date (gc, element,
487 "need-before-date", 0);
488 r->expiry_date = ill_get_ILL_ISO_Date (gc, element, "expiry-date", 0);
489 r->expiry_flag = ill_get_enumerated (gc, element, "expiry-flag", 3);
494 ILL_Request *ill_get_ILLRequest (
495 struct ill_get_ctl *gc, const char *name, const char *sub)
498 ILL_Request *r = (ILL_Request *) odr_malloc(o, sizeof(*r));
501 strcpy(element, name);
504 strcat (element, ",");
505 strcat (element, sub);
507 r->protocol_version_num =
508 ill_get_enumerated (gc, element, "protocol-version-num",
509 ILL_Request_version_2);
511 r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
512 r->service_date_time =
513 ill_get_Service_Date_Time (gc, element, "service-date-time");
514 r->requester_id = ill_get_System_Id (gc, element, "requester-id");
515 r->responder_id = ill_get_System_Id (gc, element, "responder-id");
516 r->transaction_type =
517 ill_get_enumerated(gc, element, "transaction-type", 1);
519 r->delivery_address =
520 ill_get_Delivery_Address (gc, element, "delivery-address");
521 r->delivery_service = 0; /* TODO */
522 /* ill_get_Delivery_Service (gc, element, "delivery-service"); */
524 ill_get_Delivery_Address (gc, element, "billing-address");
526 r->num_iLL_service_type = 1;
527 r->iLL_service_type = (ILL_Service_Type **)
528 odr_malloc (o, sizeof(*r->iLL_service_type));
529 *r->iLL_service_type =
530 ill_get_enumerated (gc, element, "ill-service-type",
531 ILL_Service_Type_copy_non_returnable);
533 r->responder_specific_service = 0;
534 r->requester_optional_messages =
535 ill_get_Requester_Optional_Messages_Type (
536 gc, element,"requester-optional-messages");
537 r->search_type = ill_get_Search_Type(gc, element, "search-type");
538 r->num_supply_medium_info_type = 0;
539 r->supply_medium_info_type = 0;
541 r->place_on_hold = ill_get_enumerated (
542 gc, element, "place-on-hold",
543 ILL_Place_On_Hold_Type_according_to_responder_policy);
544 r->client_id = ill_get_Client_Id (gc, element, "client-id");
546 r->item_id = ill_get_Item_Id (gc, element, "item-id");
547 r->supplemental_item_description = 0;
548 r->cost_info_type = 0;
549 r->copyright_compliance =
550 ill_get_ILL_String(gc, element, "copyright-complicance");
551 r->third_party_info_type = 0;
552 r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0);
553 r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0);
554 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
555 r->forward_note = ill_get_ILL_String(gc, element, "forward-note");
556 r->num_iLL_request_extensions = 0;
557 r->iLL_request_extensions = 0;
561 ILL_ItemRequest *ill_get_ItemRequest (
562 struct ill_get_ctl *gc, const char *name, const char *sub)
565 ILL_ItemRequest *r = (ILL_ItemRequest *)odr_malloc(o, sizeof(*r));
568 strcpy(element, name);
571 strcat (element, ",");
572 strcat (element, sub);
574 r->protocol_version_num =
575 ill_get_enumerated (gc, element, "protocol-version-num",
576 ILL_Request_version_2);
578 r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
579 r->service_date_time =
580 ill_get_Service_Date_Time (gc, element, "service-date-time");
581 r->requester_id = ill_get_System_Id (gc, element, "requester-id");
582 r->responder_id = ill_get_System_Id (gc, element, "responder-id");
583 r->transaction_type =
584 ill_get_enumerated(gc, element, "transaction-type", 1);
586 r->delivery_address =
587 ill_get_Delivery_Address (gc, element, "delivery-address");
588 r->delivery_service = 0; /* TODO */
589 /* ill_get_Delivery_Service (gc, element, "delivery-service"); */
591 ill_get_Delivery_Address (gc, element, "billing-address");
593 r->num_iLL_service_type = 1;
594 r->iLL_service_type = (ILL_Service_Type **)
595 odr_malloc (o, sizeof(*r->iLL_service_type));
596 *r->iLL_service_type =
597 ill_get_enumerated (gc, element, "ill-service-type",
598 ILL_Service_Type_copy_non_returnable);
600 r->responder_specific_service = 0;
601 r->requester_optional_messages =
602 ill_get_Requester_Optional_Messages_Type (
603 gc, element,"requester-optional-messages");
604 r->search_type = ill_get_Search_Type(gc, element, "search-type");
605 r->num_supply_medium_info_type = 0;
606 r->supply_medium_info_type = 0;
608 r->place_on_hold = ill_get_enumerated (
609 gc, element, "place-on-hold",
610 ILL_Place_On_Hold_Type_according_to_responder_policy);
611 r->client_id = ill_get_Client_Id (gc, element, "client-id");
613 r->item_id = ill_get_Item_Id (gc, element, "item-id");
614 r->supplemental_item_description = 0;
615 r->cost_info_type = 0;
616 r->copyright_compliance =
617 ill_get_ILL_String(gc, element, "copyright-complicance");
618 r->third_party_info_type = 0;
619 r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0);
620 r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0);
621 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
622 r->forward_note = ill_get_ILL_String(gc, element, "forward-note");
623 r->num_iLL_request_extensions = 0;
624 r->iLL_request_extensions = 0;
628 ILL_Cancel *ill_get_Cancel (
629 struct ill_get_ctl *gc, const char *name, const char *sub)
632 ILL_Cancel *r = (ILL_Cancel *)odr_malloc(o, sizeof(*r));
635 strcpy(element, name);
638 strcat (element, ",");
639 strcat (element, sub);
641 r->protocol_version_num =
642 ill_get_enumerated (gc, element, "protocol-version-num",
643 ILL_Request_version_2);
645 r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
646 r->service_date_time =
647 ill_get_Service_Date_Time (gc, element, "service-date-time");
648 r->requester_id = ill_get_System_Id (gc, element, "requester-id");
649 r->responder_id = ill_get_System_Id (gc, element, "responder-id");
650 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
652 r->num_cancel_extensions = 0;
653 r->cancel_extensions = 0;
657 ILL_APDU *ill_get_APDU (
658 struct ill_get_ctl *gc, const char *name, const char *sub)
661 ILL_APDU *r = (ILL_APDU *)odr_malloc(o, sizeof(*r));
665 strcpy (element, name);
666 strcat (element, ",which");
668 v = (gc->f)(gc->clientData, element);
671 if (!strcmp (v, "request"))
673 r->which = ILL_APDU_ILL_Request;
674 r->u.ILL_Request = ill_get_ILLRequest(gc, name, sub);
676 else if (!strcmp (v, "cancel"))
678 r->which = ILL_APDU_Cancel;
679 r->u.Cancel = ill_get_Cancel(gc, name, sub);