2 * Copyright (c) 1999-2000, Index Data.
3 * See the file LICENSE for details.
6 * Revision 1.6 2000-08-10 08:41:26 adam
9 * Revision 1.5 2000/02/24 08:52:01 adam
12 * Revision 1.4 2000/02/04 11:01:15 adam
13 * Added more elements.
15 * Revision 1.3 2000/01/31 13:15:21 adam
16 * Removed uses of assert(3). Cleanup of ODR. CCL parser update so
17 * that some characters are not surrounded by spaces in resulting term.
20 * Revision 1.2 2000/01/15 09:38:51 adam
21 * Implemented ill_get_ILLRequest. Added some type mappings for ILL protocol.
23 * Revision 1.1 1999/12/16 23:36:19 adam
24 * Implemented ILL protocol. Minor updates ASN.1 compiler.
30 bool_t *ill_get_bool (struct ill_get_ctl *gc, const char *name,
31 const char *sub, int val)
36 bool_t *r = odr_malloc (o, sizeof(*r));
38 strcpy(element, name);
41 strcat (element, ",");
42 strcat (element, sub);
45 v = (gc->f)(gc->clientData, element);
54 int *ill_get_int (struct ill_get_ctl *gc, const char *name,
55 const char *sub, int val)
60 int *r = odr_malloc (o, sizeof(*r));
62 strcpy(element, name);
65 strcat (element, ",");
66 strcat (element, sub);
68 v = (gc->f)(gc->clientData, element);
75 int *ill_get_enumerated (struct ill_get_ctl *gc, const char *name,
76 const char *sub, int val)
78 return ill_get_int(gc, name, sub, val);
81 ILL_String *ill_get_ILL_String_x (struct ill_get_ctl *gc, const char *name,
82 const char *sub, const char *vdefault)
84 ILL_String *r = (ILL_String *) odr_malloc (gc->odr, sizeof(*r));
88 strcpy(element, name);
91 strcat (element, ",");
92 strcat (element, sub);
94 v = (gc->f)(gc->clientData, element);
99 r->which = ILL_String_GeneralString;
100 r->u.GeneralString = odr_strdup (gc->odr, v);
104 ILL_String *ill_get_ILL_String(struct ill_get_ctl *gc, const char *name,
107 return ill_get_ILL_String_x (gc, name, sub, 0);
110 ILL_ISO_Date *ill_get_ILL_ISO_Date (struct ill_get_ctl *gc, const char *name,
111 const char *sub, const char *val)
116 strcpy(element, name);
119 strcat (element, ",");
120 strcat (element, sub);
122 v = (gc->f)(gc->clientData, element);
127 return odr_strdup (gc->odr, v);
130 ILL_ISO_Time *ill_get_ILL_ISO_Time (struct ill_get_ctl *gc, const char *name,
131 const char *sub, const char *val)
136 strcpy(element, name);
139 strcat (element, ",");
140 strcat (element, sub);
142 v = (gc->f)(gc->clientData, element);
147 return odr_strdup (gc->odr, v);
150 ILL_Person_Or_Institution_Symbol *ill_get_Person_Or_Insitution_Symbol (
151 struct ill_get_ctl *gc, const char *name, const char *sub)
155 ILL_Person_Or_Institution_Symbol *p = odr_malloc (o, sizeof(*p));
157 strcpy(element, name);
160 strcat (element, ",");
161 strcat (element, sub);
163 p->which = ILL_Person_Or_Institution_Symbol_person_symbol;
164 if ((p->u.person_symbol = ill_get_ILL_String (gc, element, "person")))
167 p->which = ILL_Person_Or_Institution_Symbol_institution_symbol;
168 if ((p->u.institution_symbol =
169 ill_get_ILL_String (gc, element, "institution")))
174 static ILL_Name_Of_Person_Or_Institution *ill_get_Name_Of_Person_Or_Institution(
175 struct ill_get_ctl *gc, const char *name, const char *sub)
179 ILL_Name_Of_Person_Or_Institution *p = odr_malloc (o, sizeof(*p));
181 strcpy(element, name);
184 strcat (element, ",");
185 strcat (element, sub);
187 p->which = ILL_Name_Of_Person_Or_Institution_name_of_person;
188 if ((p->u.name_of_person =
189 ill_get_ILL_String (gc, element, "name-of-person")))
192 p->which = ILL_Name_Of_Person_Or_Institution_name_of_institution;
193 if ((p->u.name_of_institution =
194 ill_get_ILL_String (gc, element, "name-of-institution")))
199 ILL_System_Id *ill_get_System_Id(struct ill_get_ctl *gc,
200 const char *name, const char *sub)
206 strcpy(element, name);
209 strcat (element, ",");
210 strcat (element, sub);
212 p = (ILL_System_Id *) odr_malloc (o, sizeof(*p));
213 p->person_or_institution_symbol = ill_get_Person_Or_Insitution_Symbol (
214 gc, element, "person-or-institution-symbol");
215 p->name_of_person_or_institution = ill_get_Name_Of_Person_Or_Institution (
216 gc, element, "name-of-person-or-institution");
220 ILL_Transaction_Id *ill_get_Transaction_Id (struct ill_get_ctl *gc,
221 const char *name, const char *sub)
224 ILL_Transaction_Id *r = (ILL_Transaction_Id *) odr_malloc (o, sizeof(*r));
227 strcpy(element, name);
230 strcat (element, ",");
231 strcat (element, sub);
233 r->initial_requester_id =
234 ill_get_System_Id (gc, element, "initial-requester-id");
235 r->transaction_group_qualifier =
236 ill_get_ILL_String_x (gc, element, "transaction-group-qualifier", "");
237 r->transaction_qualifier =
238 ill_get_ILL_String_x (gc, element, "transaction-qualifier", "");
239 r->sub_transaction_qualifier =
240 ill_get_ILL_String (gc, element, "sub-transaction-qualifier");
245 ILL_Service_Date_this *ill_get_Service_Date_this (
246 struct ill_get_ctl *gc, const char *name, const char *sub)
249 ILL_Service_Date_this *r =
250 (ILL_Service_Date_this *) odr_malloc (o, sizeof(*r));
253 strcpy(element, name);
256 strcat (element, ",");
257 strcat (element, sub);
259 r->date = ill_get_ILL_ISO_Date (gc, element, "date", "20000101");
260 r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
264 ILL_Service_Date_original *ill_get_Service_Date_original (
265 struct ill_get_ctl *gc, const char *name, const char *sub)
268 ILL_Service_Date_original *r =
269 (ILL_Service_Date_original *) odr_malloc (o, sizeof(*r));
272 strcpy(element, name);
275 strcat (element, ",");
276 strcat (element, sub);
278 r->date = ill_get_ILL_ISO_Date (gc, element, "date", 0);
279 r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
280 if (!r->date && !r->time)
285 ILL_Service_Date_Time *ill_get_Service_Date_Time (
286 struct ill_get_ctl *gc, const char *name, const char *sub)
289 ILL_Service_Date_Time *r =
290 (ILL_Service_Date_Time *) odr_malloc (o, sizeof(*r));
293 strcpy(element, name);
296 strcat (element, ",");
297 strcat (element, sub);
299 r->date_time_of_this_service = ill_get_Service_Date_this (
300 gc, element, "this");
301 r->date_time_of_original_service = ill_get_Service_Date_original (
302 gc, element, "original");
306 ILL_Requester_Optional_Messages_Type *ill_get_Requester_Optional_Messages_Type (
307 struct ill_get_ctl *gc, const char *name, const char *sub)
310 ILL_Requester_Optional_Messages_Type *r =
311 (ILL_Requester_Optional_Messages_Type *) odr_malloc (o, sizeof(*r));
314 strcpy(element, name);
317 strcat (element, ",");
318 strcat (element, sub);
320 r->can_send_RECEIVED = ill_get_bool (gc, element, "can-send-RECEIVED", 0);
321 r->can_send_RETURNED = ill_get_bool (gc, element, "can-send-RETURNED", 0);
322 r->requester_SHIPPED =
323 ill_get_enumerated (gc, element, "requester-SHIPPED", 1);
324 r->requester_CHECKED_IN =
325 ill_get_enumerated (gc, element, "requester-CHECKED-IN", 1);
329 ILL_Item_Id *ill_get_Item_Id (
330 struct ill_get_ctl *gc, const char *name, const char *sub)
333 ILL_Item_Id *r = (ILL_Item_Id *) odr_malloc (o, sizeof(*r));
336 strcpy(element, name);
339 strcat (element, ",");
340 strcat (element, sub);
342 r->item_type = ill_get_enumerated (gc, element, "item-type",
343 ILL_Item_Id_monograph);
344 r->held_medium_type = 0;
345 r->call_number = ill_get_ILL_String(gc, element, "call-number");
346 r->author = ill_get_ILL_String(gc, element, "author");
347 r->title = ill_get_ILL_String(gc, element, "title");
348 r->sub_title = ill_get_ILL_String(gc, element, "sub-title");
349 r->sponsoring_body = ill_get_ILL_String(gc, element, "sponsoring-body");
350 r->place_of_publication =
351 ill_get_ILL_String(gc, element, "place-of-publication");
352 r->publisher = ill_get_ILL_String(gc, element, "publisher");
353 r->series_title_number =
354 ill_get_ILL_String(gc, element, "series-title-number");
355 r->volume_issue = ill_get_ILL_String(gc, element, "volume-issue");
356 r->edition = ill_get_ILL_String(gc, element, "edition");
357 r->publication_date = ill_get_ILL_String(gc, element, "publication-date");
358 r->publication_date_of_component =
359 ill_get_ILL_String(gc, element, "publication-date-of-component");
360 r->author_of_article = ill_get_ILL_String(gc, element,
361 "author-of-article");
362 r->title_of_article = ill_get_ILL_String(gc, element, "title-of-article");
363 r->pagination = ill_get_ILL_String(gc, element, "pagination");
364 r->national_bibliography_no = 0;
365 r->iSBN = ill_get_ILL_String(gc, element, "ISBN");
366 r->iSSN = ill_get_ILL_String(gc, element, "ISSN");
368 r->additional_no_letters =
369 ill_get_ILL_String(gc, element, "additional-no-letters");
370 r->verification_reference_source =
371 ill_get_ILL_String(gc, element, "verification-reference-source");
376 ILL_Client_Id *ill_get_Client_Id (
377 struct ill_get_ctl *gc, const char *name, const char *sub)
381 ILL_Client_Id *r = (ILL_Client_Id *) odr_malloc(o, sizeof(*r));
383 strcpy(element, name);
386 strcat (element, ",");
387 strcat (element, sub);
389 r->client_name = ill_get_ILL_String (gc, element, "client-name");
390 r->client_status = ill_get_ILL_String (gc, element, "client-status");
391 r->client_identifier = ill_get_ILL_String (gc, element,
392 "client-identifier");
396 ILL_Postal_Address *ill_get_Postal_Address (
397 struct ill_get_ctl *gc, const char *name, const char *sub)
400 ILL_Postal_Address *r =
401 (ILL_Postal_Address *) odr_malloc(o, sizeof(*r));
404 strcpy(element, name);
407 strcat (element, ",");
408 strcat (element, sub);
410 r->name_of_person_or_institution =
411 ill_get_Name_Of_Person_Or_Institution (
412 gc, element, "name-of-person-or-institution");
413 r->extended_postal_delivery_address =
415 gc, element, "extended-postal-delivery-address");
416 r->street_and_number =
417 ill_get_ILL_String (gc, element, "street-and-number");
419 ill_get_ILL_String (gc, element, "post-office-box");
420 r->city = ill_get_ILL_String (gc, element, "city");
421 r->region = ill_get_ILL_String (gc, element, "region");
422 r->country = ill_get_ILL_String (gc, element, "country");
423 r->postal_code = ill_get_ILL_String (gc, element, "postal-code");
427 ILL_System_Address *ill_get_System_Address (
428 struct ill_get_ctl *gc, const char *name, const char *sub)
431 ILL_System_Address *r =
432 (ILL_System_Address *) odr_malloc(o, sizeof(*r));
435 strcpy(element, name);
438 strcat (element, ",");
439 strcat (element, sub);
441 r->telecom_service_identifier =
442 ill_get_ILL_String (gc, element, "telecom-service-identifier");
443 r->telecom_service_address =
444 ill_get_ILL_String (gc, element, "telecom-service-addreess");
448 ILL_Delivery_Address *ill_get_Delivery_Address (
449 struct ill_get_ctl *gc, const char *name, const char *sub)
452 ILL_Delivery_Address *r =
453 (ILL_Delivery_Address *) odr_malloc(o, sizeof(*r));
456 strcpy(element, name);
459 strcat (element, ",");
460 strcat (element, sub);
463 ill_get_Postal_Address (gc, element, "postal-address");
464 r->electronic_address =
465 ill_get_System_Address (gc, element, "electronic-address");
469 ILL_Search_Type *ill_get_Search_Type (
470 struct ill_get_ctl *gc, const char *name, const char *sub)
473 ILL_Search_Type *r = (ILL_Search_Type *) odr_malloc(o, sizeof(*r));
476 strcpy(element, name);
479 strcat (element, ",");
480 strcat (element, sub);
482 r->level_of_service = ill_get_ILL_String (gc, element, "level-of-service");
483 r->need_before_date = ill_get_ILL_ISO_Date (gc, element,
484 "need-before-date", 0);
485 r->expiry_date = ill_get_ILL_ISO_Date (gc, element, "expiry-date", 0);
486 r->expiry_flag = ill_get_enumerated (gc, element, "expiry-flag", 3);
491 ILL_Request *ill_get_ILLRequest (
492 struct ill_get_ctl *gc, const char *name, const char *sub)
495 ILL_Request *r = (ILL_Request *) odr_malloc(o, sizeof(*r));
498 strcpy(element, name);
501 strcat (element, ",");
502 strcat (element, sub);
504 r->protocol_version_num =
505 ill_get_enumerated (gc, element, "protocol-version-num",
506 ILL_Request_version_2);
508 r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
509 r->service_date_time =
510 ill_get_Service_Date_Time (gc, element, "service-date-time");
511 r->requester_id = ill_get_System_Id (gc, element, "requester-id");
512 r->responder_id = ill_get_System_Id (gc, element, "responder-id");
513 r->transaction_type =
514 ill_get_enumerated(gc, element, "transaction-type", 1);
516 r->delivery_address =
517 ill_get_Delivery_Address (gc, element, "delivery-address");
518 r->delivery_service = 0; /* TODO */
519 /* ill_get_Delivery_Service (gc, element, "delivery-service"); */
521 ill_get_Delivery_Address (gc, element, "billing-address");
523 r->num_iLL_service_type = 1;
524 r->iLL_service_type = (ILL_Service_Type **)
525 odr_malloc (o, sizeof(*r->iLL_service_type));
526 *r->iLL_service_type =
527 ill_get_enumerated (gc, element, "ill-service-type",
528 ILL_Service_Type_copy_non_returnable);
530 r->responder_specific_service = 0;
531 r->requester_optional_messages =
532 ill_get_Requester_Optional_Messages_Type (
533 gc, element,"requester-optional-messages");
534 r->search_type = ill_get_Search_Type(gc, element, "search-type");
535 r->num_supply_medium_info_type = 0;
536 r->supply_medium_info_type = 0;
538 r->place_on_hold = ill_get_enumerated (
539 gc, element, "place-on-hold",
540 ILL_Place_On_Hold_Type_according_to_responder_policy);
541 r->client_id = ill_get_Client_Id (gc, element, "client-id");
543 r->item_id = ill_get_Item_Id (gc, element, "item-id");
544 r->supplemental_item_description = 0;
545 r->cost_info_type = 0;
546 r->copyright_compliance =
547 ill_get_ILL_String(gc, element, "copyright-complicance");
548 r->third_party_info_type = 0;
549 r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0);
550 r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0);
551 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
552 r->forward_note = ill_get_ILL_String(gc, element, "forward-note");
553 r->num_iLL_request_extensions = 0;
554 r->iLL_request_extensions = 0;
558 ILL_ItemRequest *ill_get_ItemRequest (
559 struct ill_get_ctl *gc, const char *name, const char *sub)
562 ILL_ItemRequest *r = (ILL_ItemRequest *)odr_malloc(o, sizeof(*r));
565 strcpy(element, name);
568 strcat (element, ",");
569 strcat (element, sub);
571 r->protocol_version_num =
572 ill_get_enumerated (gc, element, "protocol-version-num",
573 ILL_Request_version_2);
575 r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
576 r->service_date_time =
577 ill_get_Service_Date_Time (gc, element, "service-date-time");
578 r->requester_id = ill_get_System_Id (gc, element, "requester-id");
579 r->responder_id = ill_get_System_Id (gc, element, "responder-id");
580 r->transaction_type =
581 ill_get_enumerated(gc, element, "transaction-type", 1);
583 r->delivery_address =
584 ill_get_Delivery_Address (gc, element, "delivery-address");
585 r->delivery_service = 0; /* TODO */
586 /* ill_get_Delivery_Service (gc, element, "delivery-service"); */
588 ill_get_Delivery_Address (gc, element, "billing-address");
590 r->num_iLL_service_type = 1;
591 r->iLL_service_type = (ILL_Service_Type **)
592 odr_malloc (o, sizeof(*r->iLL_service_type));
593 *r->iLL_service_type =
594 ill_get_enumerated (gc, element, "ill-service-type",
595 ILL_Service_Type_copy_non_returnable);
597 r->responder_specific_service = 0;
598 r->requester_optional_messages =
599 ill_get_Requester_Optional_Messages_Type (
600 gc, element,"requester-optional-messages");
601 r->search_type = ill_get_Search_Type(gc, element, "search-type");
602 r->num_supply_medium_info_type = 0;
603 r->supply_medium_info_type = 0;
605 r->place_on_hold = ill_get_enumerated (
606 gc, element, "place-on-hold",
607 ILL_Place_On_Hold_Type_according_to_responder_policy);
608 r->client_id = ill_get_Client_Id (gc, element, "client-id");
610 r->item_id = ill_get_Item_Id (gc, element, "item-id");
611 r->supplemental_item_description = 0;
612 r->cost_info_type = 0;
613 r->copyright_compliance =
614 ill_get_ILL_String(gc, element, "copyright-complicance");
615 r->third_party_info_type = 0;
616 r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0);
617 r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0);
618 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
619 r->forward_note = ill_get_ILL_String(gc, element, "forward-note");
620 r->num_iLL_request_extensions = 0;
621 r->iLL_request_extensions = 0;