1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2009 Index Data
3 * See the file LICENSE for details.
8 * \brief Implements ILL package creator utilities
14 bool_t *ill_get_bool (struct ill_get_ctl *gc, const char *name,
15 const char *sub, int val)
20 bool_t *r = (bool_t *) odr_malloc (o, sizeof(*r));
22 strcpy(element, name);
25 strcat (element, ",");
26 strcat (element, sub);
29 v = (gc->f)(gc->clientData, element);
38 Odr_int *ill_get_int(struct ill_get_ctl *gc, const char *name,
39 const char *sub, Odr_int val)
45 strcpy(element, name);
48 strcat (element, ",");
49 strcat (element, sub);
51 v = (gc->f)(gc->clientData, element);
54 return odr_intdup(o, val);
57 Odr_int *ill_get_enumerated (struct ill_get_ctl *gc, const char *name,
58 const char *sub, Odr_int val)
60 return ill_get_int(gc, name, sub, val);
63 ILL_String *ill_get_ILL_String_x (struct ill_get_ctl *gc, const char *name,
64 const char *sub, const char *vdefault)
66 ILL_String *r = (ILL_String *) odr_malloc (gc->odr, sizeof(*r));
70 strcpy(element, name);
73 strcat (element, ",");
74 strcat (element, sub);
76 v = (gc->f)(gc->clientData, element);
81 r->which = ILL_String_GeneralString;
82 r->u.GeneralString = odr_strdup (gc->odr, v);
86 ILL_String *ill_get_ILL_String(struct ill_get_ctl *gc, const char *name,
89 return ill_get_ILL_String_x (gc, name, sub, 0);
92 ILL_ISO_Date *ill_get_ILL_ISO_Date (struct ill_get_ctl *gc, const char *name,
93 const char *sub, const char *val)
98 strcpy(element, name);
101 strcat (element, ",");
102 strcat (element, sub);
104 v = (gc->f)(gc->clientData, element);
109 return odr_strdup (gc->odr, v);
112 ILL_ISO_Time *ill_get_ILL_ISO_Time (struct ill_get_ctl *gc, const char *name,
113 const char *sub, const char *val)
118 strcpy(element, name);
121 strcat (element, ",");
122 strcat (element, sub);
124 v = (gc->f)(gc->clientData, element);
129 return odr_strdup (gc->odr, v);
132 ILL_Person_Or_Institution_Symbol *ill_get_Person_Or_Insitution_Symbol (
133 struct ill_get_ctl *gc, const char *name, const char *sub)
137 ILL_Person_Or_Institution_Symbol *p =
138 (ILL_Person_Or_Institution_Symbol *) odr_malloc (o, sizeof(*p));
140 strcpy(element, name);
143 strcat (element, ",");
144 strcat (element, sub);
146 p->which = ILL_Person_Or_Institution_Symbol_person_symbol;
147 if ((p->u.person_symbol = ill_get_ILL_String (gc, element, "person")))
150 p->which = ILL_Person_Or_Institution_Symbol_institution_symbol;
151 if ((p->u.institution_symbol =
152 ill_get_ILL_String (gc, element, "institution")))
157 static ILL_Name_Of_Person_Or_Institution *ill_get_Name_Of_Person_Or_Institution(
158 struct ill_get_ctl *gc, const char *name, const char *sub)
162 ILL_Name_Of_Person_Or_Institution *p =
163 (ILL_Name_Of_Person_Or_Institution *) odr_malloc (o, sizeof(*p));
165 strcpy(element, name);
168 strcat (element, ",");
169 strcat (element, sub);
171 p->which = ILL_Name_Of_Person_Or_Institution_name_of_person;
172 if ((p->u.name_of_person =
173 ill_get_ILL_String (gc, element, "name-of-person")))
176 p->which = ILL_Name_Of_Person_Or_Institution_name_of_institution;
177 if ((p->u.name_of_institution =
178 ill_get_ILL_String (gc, element, "name-of-institution")))
183 ILL_System_Id *ill_get_System_Id(struct ill_get_ctl *gc,
184 const char *name, const char *sub)
190 strcpy(element, name);
193 strcat (element, ",");
194 strcat (element, sub);
196 p = (ILL_System_Id *) odr_malloc (o, sizeof(*p));
197 p->person_or_institution_symbol = ill_get_Person_Or_Insitution_Symbol (
198 gc, element, "person-or-institution-symbol");
199 p->name_of_person_or_institution = ill_get_Name_Of_Person_Or_Institution (
200 gc, element, "name-of-person-or-institution");
204 ILL_Transaction_Id *ill_get_Transaction_Id (struct ill_get_ctl *gc,
205 const char *name, const char *sub)
208 ILL_Transaction_Id *r = (ILL_Transaction_Id *) odr_malloc (o, sizeof(*r));
211 strcpy(element, name);
214 strcat (element, ",");
215 strcat (element, sub);
217 r->initial_requester_id =
218 ill_get_System_Id (gc, element, "initial-requester-id");
219 r->transaction_group_qualifier =
220 ill_get_ILL_String_x (gc, element, "transaction-group-qualifier", "");
221 r->transaction_qualifier =
222 ill_get_ILL_String_x (gc, element, "transaction-qualifier", "");
223 r->sub_transaction_qualifier =
224 ill_get_ILL_String (gc, element, "sub-transaction-qualifier");
229 ILL_Service_Date_this *ill_get_Service_Date_this (
230 struct ill_get_ctl *gc, const char *name, const char *sub)
233 ILL_Service_Date_this *r =
234 (ILL_Service_Date_this *) odr_malloc (o, sizeof(*r));
237 strcpy(element, name);
240 strcat (element, ",");
241 strcat (element, sub);
243 r->date = ill_get_ILL_ISO_Date (gc, element, "date", "20000101");
244 r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
248 ILL_Service_Date_original *ill_get_Service_Date_original (
249 struct ill_get_ctl *gc, const char *name, const char *sub)
252 ILL_Service_Date_original *r =
253 (ILL_Service_Date_original *) 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", 0);
263 r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
264 if (!r->date && !r->time)
269 ILL_Service_Date_Time *ill_get_Service_Date_Time (
270 struct ill_get_ctl *gc, const char *name, const char *sub)
273 ILL_Service_Date_Time *r =
274 (ILL_Service_Date_Time *) odr_malloc (o, sizeof(*r));
277 strcpy(element, name);
280 strcat (element, ",");
281 strcat (element, sub);
283 r->date_time_of_this_service = ill_get_Service_Date_this (
284 gc, element, "this");
285 r->date_time_of_original_service = ill_get_Service_Date_original (
286 gc, element, "original");
290 ILL_Requester_Optional_Messages_Type *ill_get_Requester_Optional_Messages_Type (
291 struct ill_get_ctl *gc, const char *name, const char *sub)
294 ILL_Requester_Optional_Messages_Type *r =
295 (ILL_Requester_Optional_Messages_Type *) odr_malloc (o, sizeof(*r));
298 strcpy(element, name);
301 strcat (element, ",");
302 strcat (element, sub);
304 r->can_send_RECEIVED = ill_get_bool (gc, element, "can-send-RECEIVED", 0);
305 r->can_send_RETURNED = ill_get_bool (gc, element, "can-send-RETURNED", 0);
306 r->requester_SHIPPED =
307 ill_get_enumerated (gc, element, "requester-SHIPPED", 1);
308 r->requester_CHECKED_IN =
309 ill_get_enumerated (gc, element, "requester-CHECKED-IN", 1);
313 ILL_Item_Id *ill_get_Item_Id (
314 struct ill_get_ctl *gc, const char *name, const char *sub)
317 ILL_Item_Id *r = (ILL_Item_Id *) odr_malloc (o, sizeof(*r));
320 strcpy(element, name);
323 strcat (element, ",");
324 strcat (element, sub);
326 r->item_type = ill_get_enumerated (gc, element, "item-type",
327 ILL_Item_Id_monograph);
328 r->held_medium_type = 0;
329 r->call_number = ill_get_ILL_String(gc, element, "call-number");
330 r->author = ill_get_ILL_String(gc, element, "author");
331 r->title = ill_get_ILL_String(gc, element, "title");
332 r->sub_title = ill_get_ILL_String(gc, element, "sub-title");
333 r->sponsoring_body = ill_get_ILL_String(gc, element, "sponsoring-body");
334 r->place_of_publication =
335 ill_get_ILL_String(gc, element, "place-of-publication");
336 r->publisher = ill_get_ILL_String(gc, element, "publisher");
337 r->series_title_number =
338 ill_get_ILL_String(gc, element, "series-title-number");
339 r->volume_issue = ill_get_ILL_String(gc, element, "volume-issue");
340 r->edition = ill_get_ILL_String(gc, element, "edition");
341 r->publication_date = ill_get_ILL_String(gc, element, "publication-date");
342 r->publication_date_of_component =
343 ill_get_ILL_String(gc, element, "publication-date-of-component");
344 r->author_of_article = ill_get_ILL_String(gc, element,
345 "author-of-article");
346 r->title_of_article = ill_get_ILL_String(gc, element, "title-of-article");
347 r->pagination = ill_get_ILL_String(gc, element, "pagination");
348 r->national_bibliography_no = 0;
349 r->iSBN = ill_get_ILL_String(gc, element, "ISBN");
350 r->iSSN = ill_get_ILL_String(gc, element, "ISSN");
352 r->additional_no_letters =
353 ill_get_ILL_String(gc, element, "additional-no-letters");
354 r->verification_reference_source =
355 ill_get_ILL_String(gc, element, "verification-reference-source");
360 ILL_Client_Id *ill_get_Client_Id (
361 struct ill_get_ctl *gc, const char *name, const char *sub)
365 ILL_Client_Id *r = (ILL_Client_Id *) odr_malloc(o, sizeof(*r));
367 strcpy(element, name);
370 strcat (element, ",");
371 strcat (element, sub);
373 r->client_name = ill_get_ILL_String (gc, element, "client-name");
374 r->client_status = ill_get_ILL_String (gc, element, "client-status");
375 r->client_identifier = ill_get_ILL_String (gc, element,
376 "client-identifier");
380 ILL_Postal_Address *ill_get_Postal_Address (
381 struct ill_get_ctl *gc, const char *name, const char *sub)
384 ILL_Postal_Address *r =
385 (ILL_Postal_Address *) odr_malloc(o, sizeof(*r));
388 strcpy(element, name);
391 strcat (element, ",");
392 strcat (element, sub);
394 r->name_of_person_or_institution =
395 ill_get_Name_Of_Person_Or_Institution (
396 gc, element, "name-of-person-or-institution");
397 r->extended_postal_delivery_address =
399 gc, element, "extended-postal-delivery-address");
400 r->street_and_number =
401 ill_get_ILL_String (gc, element, "street-and-number");
403 ill_get_ILL_String (gc, element, "post-office-box");
404 r->city = ill_get_ILL_String (gc, element, "city");
405 r->region = ill_get_ILL_String (gc, element, "region");
406 r->country = ill_get_ILL_String (gc, element, "country");
407 r->postal_code = ill_get_ILL_String (gc, element, "postal-code");
411 ILL_System_Address *ill_get_System_Address (
412 struct ill_get_ctl *gc, const char *name, const char *sub)
415 ILL_System_Address *r =
416 (ILL_System_Address *) odr_malloc(o, sizeof(*r));
419 strcpy(element, name);
422 strcat (element, ",");
423 strcat (element, sub);
425 r->telecom_service_identifier =
426 ill_get_ILL_String (gc, element, "telecom-service-identifier");
427 r->telecom_service_address =
428 ill_get_ILL_String (gc, element, "telecom-service-addreess");
432 ILL_Delivery_Address *ill_get_Delivery_Address (
433 struct ill_get_ctl *gc, const char *name, const char *sub)
436 ILL_Delivery_Address *r =
437 (ILL_Delivery_Address *) odr_malloc(o, sizeof(*r));
440 strcpy(element, name);
443 strcat (element, ",");
444 strcat (element, sub);
447 ill_get_Postal_Address (gc, element, "postal-address");
448 r->electronic_address =
449 ill_get_System_Address (gc, element, "electronic-address");
453 ILL_Search_Type *ill_get_Search_Type (
454 struct ill_get_ctl *gc, const char *name, const char *sub)
457 ILL_Search_Type *r = (ILL_Search_Type *) odr_malloc(o, sizeof(*r));
460 strcpy(element, name);
463 strcat (element, ",");
464 strcat (element, sub);
466 r->level_of_service = ill_get_ILL_String (gc, element, "level-of-service");
467 r->need_before_date = ill_get_ILL_ISO_Date (gc, element,
468 "need-before-date", 0);
469 r->expiry_date = ill_get_ILL_ISO_Date (gc, element, "expiry-date", 0);
470 r->expiry_flag = ill_get_enumerated (gc, element, "expiry-flag", 3);
475 ILL_Request *ill_get_ILLRequest (
476 struct ill_get_ctl *gc, const char *name, const char *sub)
479 ILL_Request *r = (ILL_Request *) odr_malloc(o, sizeof(*r));
482 strcpy(element, name);
485 strcat (element, ",");
486 strcat (element, sub);
488 r->protocol_version_num =
489 ill_get_enumerated (gc, element, "protocol-version-num",
490 ILL_Request_version_2);
492 r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
493 r->service_date_time =
494 ill_get_Service_Date_Time (gc, element, "service-date-time");
495 r->requester_id = ill_get_System_Id (gc, element, "requester-id");
496 r->responder_id = ill_get_System_Id (gc, element, "responder-id");
497 r->transaction_type =
498 ill_get_enumerated(gc, element, "transaction-type", 1);
500 r->delivery_address =
501 ill_get_Delivery_Address (gc, element, "delivery-address");
502 r->delivery_service = 0; /* TODO */
503 /* ill_get_Delivery_Service (gc, element, "delivery-service"); */
505 ill_get_Delivery_Address (gc, element, "billing-address");
507 r->num_iLL_service_type = 1;
508 r->iLL_service_type = (ILL_Service_Type **)
509 odr_malloc (o, sizeof(*r->iLL_service_type));
510 *r->iLL_service_type =
511 ill_get_enumerated (gc, element, "ill-service-type",
512 ILL_Service_Type_copy_non_returnable);
514 r->responder_specific_service = 0;
515 r->requester_optional_messages =
516 ill_get_Requester_Optional_Messages_Type (
517 gc, element,"requester-optional-messages");
518 r->search_type = ill_get_Search_Type(gc, element, "search-type");
519 r->num_supply_medium_info_type = 0;
520 r->supply_medium_info_type = 0;
522 r->place_on_hold = ill_get_enumerated (
523 gc, element, "place-on-hold",
524 ILL_Place_On_Hold_Type_according_to_responder_policy);
525 r->client_id = ill_get_Client_Id (gc, element, "client-id");
527 r->item_id = ill_get_Item_Id (gc, element, "item-id");
528 r->supplemental_item_description = 0;
529 r->cost_info_type = 0;
530 r->copyright_compliance =
531 ill_get_ILL_String(gc, element, "copyright-complicance");
532 r->third_party_info_type = 0;
533 r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0);
534 r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0);
535 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
536 r->forward_note = ill_get_ILL_String(gc, element, "forward-note");
537 r->num_iLL_request_extensions = 0;
538 r->iLL_request_extensions = 0;
542 ILL_ItemRequest *ill_get_ItemRequest (
543 struct ill_get_ctl *gc, const char *name, const char *sub)
546 ILL_ItemRequest *r = (ILL_ItemRequest *)odr_malloc(o, sizeof(*r));
549 strcpy(element, name);
552 strcat (element, ",");
553 strcat (element, sub);
555 r->protocol_version_num =
556 ill_get_enumerated (gc, element, "protocol-version-num",
557 ILL_Request_version_2);
559 r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
560 r->service_date_time =
561 ill_get_Service_Date_Time (gc, element, "service-date-time");
562 r->requester_id = ill_get_System_Id (gc, element, "requester-id");
563 r->responder_id = ill_get_System_Id (gc, element, "responder-id");
564 r->transaction_type =
565 ill_get_enumerated(gc, element, "transaction-type", 1);
567 r->delivery_address =
568 ill_get_Delivery_Address (gc, element, "delivery-address");
569 r->delivery_service = 0; /* TODO */
570 /* ill_get_Delivery_Service (gc, element, "delivery-service"); */
572 ill_get_Delivery_Address (gc, element, "billing-address");
574 r->num_iLL_service_type = 1;
575 r->iLL_service_type = (ILL_Service_Type **)
576 odr_malloc (o, sizeof(*r->iLL_service_type));
577 *r->iLL_service_type =
578 ill_get_enumerated (gc, element, "ill-service-type",
579 ILL_Service_Type_copy_non_returnable);
581 r->responder_specific_service = 0;
582 r->requester_optional_messages =
583 ill_get_Requester_Optional_Messages_Type (
584 gc, element,"requester-optional-messages");
585 r->search_type = ill_get_Search_Type(gc, element, "search-type");
586 r->num_supply_medium_info_type = 0;
587 r->supply_medium_info_type = 0;
589 r->place_on_hold = ill_get_enumerated (
590 gc, element, "place-on-hold",
591 ILL_Place_On_Hold_Type_according_to_responder_policy);
592 r->client_id = ill_get_Client_Id (gc, element, "client-id");
594 r->item_id = ill_get_Item_Id (gc, element, "item-id");
595 r->supplemental_item_description = 0;
596 r->cost_info_type = 0;
597 r->copyright_compliance =
598 ill_get_ILL_String(gc, element, "copyright-complicance");
599 r->third_party_info_type = 0;
600 r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0);
601 r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0);
602 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
603 r->forward_note = ill_get_ILL_String(gc, element, "forward-note");
604 r->num_iLL_request_extensions = 0;
605 r->iLL_request_extensions = 0;
609 ILL_Cancel *ill_get_Cancel (
610 struct ill_get_ctl *gc, const char *name, const char *sub)
613 ILL_Cancel *r = (ILL_Cancel *)odr_malloc(o, sizeof(*r));
616 strcpy(element, name);
619 strcat (element, ",");
620 strcat (element, sub);
622 r->protocol_version_num =
623 ill_get_enumerated (gc, element, "protocol-version-num",
624 ILL_Request_version_2);
626 r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
627 r->service_date_time =
628 ill_get_Service_Date_Time (gc, element, "service-date-time");
629 r->requester_id = ill_get_System_Id (gc, element, "requester-id");
630 r->responder_id = ill_get_System_Id (gc, element, "responder-id");
631 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
633 r->num_cancel_extensions = 0;
634 r->cancel_extensions = 0;
638 ILL_APDU *ill_get_APDU (
639 struct ill_get_ctl *gc, const char *name, const char *sub)
642 ILL_APDU *r = (ILL_APDU *)odr_malloc(o, sizeof(*r));
646 strcpy (element, name);
647 strcat (element, ",which");
649 v = (gc->f)(gc->clientData, element);
652 if (!strcmp (v, "request"))
654 r->which = ILL_APDU_ILL_Request;
655 r->u.illRequest = ill_get_ILLRequest(gc, name, sub);
657 else if (!strcmp (v, "cancel"))
659 r->which = ILL_APDU_Cancel;
660 r->u.Cancel = ill_get_Cancel(gc, name, sub);
669 * c-file-style: "Stroustrup"
670 * indent-tabs-mode: nil
672 * vim: shiftwidth=4 tabstop=8 expandtab