1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2011 Index Data
3 * See the file LICENSE for details.
7 * \brief Implements ILL package creator utilities
16 bool_t *ill_get_bool(struct ill_get_ctl *gc, const char *name,
17 const char *sub, int val)
22 bool_t *r = (bool_t *) odr_malloc(o, sizeof(*r));
24 strcpy(element, name);
31 v = (gc->f)(gc->clientData, element);
40 Odr_int *ill_get_int(struct ill_get_ctl *gc, const char *name,
41 const char *sub, Odr_int val)
47 strcpy(element, name);
53 v = (gc->f)(gc->clientData, element);
56 return odr_intdup(o, val);
59 Odr_int *ill_get_enumerated(struct ill_get_ctl *gc, const char *name,
60 const char *sub, Odr_int val)
62 return ill_get_int(gc, name, sub, val);
65 ILL_String *ill_get_ILL_String_x(struct ill_get_ctl *gc, const char *name,
66 const char *sub, const char *vdefault)
68 ILL_String *r = (ILL_String *) odr_malloc(gc->odr, sizeof(*r));
72 strcpy(element, name);
78 v = (gc->f)(gc->clientData, element);
83 r->which = ILL_String_GeneralString;
84 r->u.GeneralString = odr_strdup(gc->odr, v);
88 ILL_String *ill_get_ILL_String(struct ill_get_ctl *gc, const char *name,
91 return ill_get_ILL_String_x(gc, name, sub, 0);
94 ILL_ISO_Date *ill_get_ILL_ISO_Date(struct ill_get_ctl *gc, const char *name,
95 const char *sub, const char *val)
100 strcpy(element, name);
103 strcat(element, ",");
104 strcat(element, sub);
106 v = (gc->f)(gc->clientData, element);
111 return odr_strdup(gc->odr, v);
114 ILL_ISO_Time *ill_get_ILL_ISO_Time(struct ill_get_ctl *gc, const char *name,
115 const char *sub, const char *val)
120 strcpy(element, name);
123 strcat(element, ",");
124 strcat(element, sub);
126 v = (gc->f)(gc->clientData, element);
131 return odr_strdup(gc->odr, v);
134 ILL_Person_Or_Institution_Symbol *ill_get_Person_Or_Insitution_Symbol(
135 struct ill_get_ctl *gc, const char *name, const char *sub)
139 ILL_Person_Or_Institution_Symbol *p =
140 (ILL_Person_Or_Institution_Symbol *) odr_malloc(o, sizeof(*p));
142 strcpy(element, name);
145 strcat(element, ",");
146 strcat(element, sub);
148 p->which = ILL_Person_Or_Institution_Symbol_person_symbol;
149 if ((p->u.person_symbol = ill_get_ILL_String(gc, element, "person")))
152 p->which = ILL_Person_Or_Institution_Symbol_institution_symbol;
153 if ((p->u.institution_symbol =
154 ill_get_ILL_String(gc, element, "institution")))
159 static ILL_Name_Of_Person_Or_Institution *ill_get_Name_Of_Person_Or_Institution(
160 struct ill_get_ctl *gc, const char *name, const char *sub)
164 ILL_Name_Of_Person_Or_Institution *p =
165 (ILL_Name_Of_Person_Or_Institution *) odr_malloc(o, sizeof(*p));
167 strcpy(element, name);
170 strcat(element, ",");
171 strcat(element, sub);
173 p->which = ILL_Name_Of_Person_Or_Institution_name_of_person;
174 if ((p->u.name_of_person =
175 ill_get_ILL_String(gc, element, "name-of-person")))
178 p->which = ILL_Name_Of_Person_Or_Institution_name_of_institution;
179 if ((p->u.name_of_institution =
180 ill_get_ILL_String(gc, element, "name-of-institution")))
185 ILL_System_Id *ill_get_System_Id(struct ill_get_ctl *gc,
186 const char *name, const char *sub)
192 strcpy(element, name);
195 strcat(element, ",");
196 strcat(element, sub);
198 p = (ILL_System_Id *) odr_malloc(o, sizeof(*p));
199 p->person_or_institution_symbol = ill_get_Person_Or_Insitution_Symbol(
200 gc, element, "person-or-institution-symbol");
201 p->name_of_person_or_institution = ill_get_Name_Of_Person_Or_Institution(
202 gc, element, "name-of-person-or-institution");
206 ILL_Transaction_Id *ill_get_Transaction_Id(struct ill_get_ctl *gc,
207 const char *name, const char *sub)
210 ILL_Transaction_Id *r = (ILL_Transaction_Id *) odr_malloc(o, sizeof(*r));
213 strcpy(element, name);
216 strcat(element, ",");
217 strcat(element, sub);
219 r->initial_requester_id =
220 ill_get_System_Id(gc, element, "initial-requester-id");
221 r->transaction_group_qualifier =
222 ill_get_ILL_String_x(gc, element, "transaction-group-qualifier", "");
223 r->transaction_qualifier =
224 ill_get_ILL_String_x(gc, element, "transaction-qualifier", "");
225 r->sub_transaction_qualifier =
226 ill_get_ILL_String(gc, element, "sub-transaction-qualifier");
231 ILL_Service_Date_this *ill_get_Service_Date_this(
232 struct ill_get_ctl *gc, const char *name, const char *sub)
235 ILL_Service_Date_this *r =
236 (ILL_Service_Date_this *) odr_malloc(o, sizeof(*r));
239 strcpy(element, name);
242 strcat(element, ",");
243 strcat(element, sub);
245 r->date = ill_get_ILL_ISO_Date(gc, element, "date", "20000101");
246 r->time = ill_get_ILL_ISO_Time(gc, element, "time", 0);
250 ILL_Service_Date_original *ill_get_Service_Date_original(
251 struct ill_get_ctl *gc, const char *name, const char *sub)
254 ILL_Service_Date_original *r =
255 (ILL_Service_Date_original *) odr_malloc(o, sizeof(*r));
258 strcpy(element, name);
261 strcat(element, ",");
262 strcat(element, sub);
264 r->date = ill_get_ILL_ISO_Date(gc, element, "date", 0);
265 r->time = ill_get_ILL_ISO_Time(gc, element, "time", 0);
266 if (!r->date && !r->time)
271 ILL_Service_Date_Time *ill_get_Service_Date_Time(
272 struct ill_get_ctl *gc, const char *name, const char *sub)
275 ILL_Service_Date_Time *r =
276 (ILL_Service_Date_Time *) odr_malloc(o, sizeof(*r));
279 strcpy(element, name);
282 strcat(element, ",");
283 strcat(element, sub);
285 r->date_time_of_this_service = ill_get_Service_Date_this(
286 gc, element, "this");
287 r->date_time_of_original_service = ill_get_Service_Date_original(
288 gc, element, "original");
292 ILL_Requester_Optional_Messages_Type *ill_get_Requester_Optional_Messages_Type(
293 struct ill_get_ctl *gc, const char *name, const char *sub)
296 ILL_Requester_Optional_Messages_Type *r =
297 (ILL_Requester_Optional_Messages_Type *) odr_malloc(o, sizeof(*r));
300 strcpy(element, name);
303 strcat(element, ",");
304 strcat(element, sub);
306 r->can_send_RECEIVED = ill_get_bool(gc, element, "can-send-RECEIVED", 0);
307 r->can_send_RETURNED = ill_get_bool(gc, element, "can-send-RETURNED", 0);
308 r->requester_SHIPPED =
309 ill_get_enumerated(gc, element, "requester-SHIPPED", 1);
310 r->requester_CHECKED_IN =
311 ill_get_enumerated(gc, element, "requester-CHECKED-IN", 1);
315 ILL_Item_Id *ill_get_Item_Id(
316 struct ill_get_ctl *gc, const char *name, const char *sub)
319 ILL_Item_Id *r = (ILL_Item_Id *) odr_malloc(o, sizeof(*r));
322 strcpy(element, name);
325 strcat(element, ",");
326 strcat(element, sub);
328 r->item_type = ill_get_enumerated(gc, element, "item-type",
329 ILL_Item_Id_monograph);
330 r->held_medium_type = 0;
331 r->call_number = ill_get_ILL_String(gc, element, "call-number");
332 r->author = ill_get_ILL_String(gc, element, "author");
333 r->title = ill_get_ILL_String(gc, element, "title");
334 r->sub_title = ill_get_ILL_String(gc, element, "sub-title");
335 r->sponsoring_body = ill_get_ILL_String(gc, element, "sponsoring-body");
336 r->place_of_publication =
337 ill_get_ILL_String(gc, element, "place-of-publication");
338 r->publisher = ill_get_ILL_String(gc, element, "publisher");
339 r->series_title_number =
340 ill_get_ILL_String(gc, element, "series-title-number");
341 r->volume_issue = ill_get_ILL_String(gc, element, "volume-issue");
342 r->edition = ill_get_ILL_String(gc, element, "edition");
343 r->publication_date = ill_get_ILL_String(gc, element, "publication-date");
344 r->publication_date_of_component =
345 ill_get_ILL_String(gc, element, "publication-date-of-component");
346 r->author_of_article = ill_get_ILL_String(gc, element,
347 "author-of-article");
348 r->title_of_article = ill_get_ILL_String(gc, element, "title-of-article");
349 r->pagination = ill_get_ILL_String(gc, element, "pagination");
350 r->national_bibliography_no = 0;
351 r->iSBN = ill_get_ILL_String(gc, element, "ISBN");
352 r->iSSN = ill_get_ILL_String(gc, element, "ISSN");
354 r->additional_no_letters =
355 ill_get_ILL_String(gc, element, "additional-no-letters");
356 r->verification_reference_source =
357 ill_get_ILL_String(gc, element, "verification-reference-source");
362 ILL_Client_Id *ill_get_Client_Id(
363 struct ill_get_ctl *gc, const char *name, const char *sub)
367 ILL_Client_Id *r = (ILL_Client_Id *) odr_malloc(o, sizeof(*r));
369 strcpy(element, name);
372 strcat(element, ",");
373 strcat(element, sub);
375 r->client_name = ill_get_ILL_String(gc, element, "client-name");
376 r->client_status = ill_get_ILL_String(gc, element, "client-status");
377 r->client_identifier = ill_get_ILL_String(gc, element,
378 "client-identifier");
382 ILL_Postal_Address *ill_get_Postal_Address(
383 struct ill_get_ctl *gc, const char *name, const char *sub)
386 ILL_Postal_Address *r =
387 (ILL_Postal_Address *) odr_malloc(o, sizeof(*r));
390 strcpy(element, name);
393 strcat(element, ",");
394 strcat(element, sub);
396 r->name_of_person_or_institution =
397 ill_get_Name_Of_Person_Or_Institution(
398 gc, element, "name-of-person-or-institution");
399 r->extended_postal_delivery_address =
401 gc, element, "extended-postal-delivery-address");
402 r->street_and_number =
403 ill_get_ILL_String(gc, element, "street-and-number");
405 ill_get_ILL_String(gc, element, "post-office-box");
406 r->city = ill_get_ILL_String(gc, element, "city");
407 r->region = ill_get_ILL_String(gc, element, "region");
408 r->country = ill_get_ILL_String(gc, element, "country");
409 r->postal_code = ill_get_ILL_String(gc, element, "postal-code");
413 ILL_System_Address *ill_get_System_Address(
414 struct ill_get_ctl *gc, const char *name, const char *sub)
417 ILL_System_Address *r =
418 (ILL_System_Address *) odr_malloc(o, sizeof(*r));
421 strcpy(element, name);
424 strcat(element, ",");
425 strcat(element, sub);
427 r->telecom_service_identifier =
428 ill_get_ILL_String(gc, element, "telecom-service-identifier");
429 r->telecom_service_address =
430 ill_get_ILL_String(gc, element, "telecom-service-addreess");
434 ILL_Delivery_Address *ill_get_Delivery_Address(
435 struct ill_get_ctl *gc, const char *name, const char *sub)
438 ILL_Delivery_Address *r =
439 (ILL_Delivery_Address *) odr_malloc(o, sizeof(*r));
442 strcpy(element, name);
445 strcat(element, ",");
446 strcat(element, sub);
449 ill_get_Postal_Address(gc, element, "postal-address");
450 r->electronic_address =
451 ill_get_System_Address(gc, element, "electronic-address");
455 ILL_Search_Type *ill_get_Search_Type(
456 struct ill_get_ctl *gc, const char *name, const char *sub)
459 ILL_Search_Type *r = (ILL_Search_Type *) odr_malloc(o, sizeof(*r));
462 strcpy(element, name);
465 strcat(element, ",");
466 strcat(element, sub);
468 r->level_of_service = ill_get_ILL_String(gc, element, "level-of-service");
469 r->need_before_date = ill_get_ILL_ISO_Date(gc, element,
470 "need-before-date", 0);
471 r->expiry_date = ill_get_ILL_ISO_Date(gc, element, "expiry-date", 0);
472 r->expiry_flag = ill_get_enumerated(gc, element, "expiry-flag", 3);
477 ILL_Request *ill_get_ILLRequest(
478 struct ill_get_ctl *gc, const char *name, const char *sub)
481 ILL_Request *r = (ILL_Request *) odr_malloc(o, sizeof(*r));
484 strcpy(element, name);
487 strcat(element, ",");
488 strcat(element, sub);
490 r->protocol_version_num =
491 ill_get_enumerated(gc, element, "protocol-version-num",
492 ILL_Request_version_2);
494 r->transaction_id = ill_get_Transaction_Id(gc, element, "transaction-id");
495 r->service_date_time =
496 ill_get_Service_Date_Time(gc, element, "service-date-time");
497 r->requester_id = ill_get_System_Id(gc, element, "requester-id");
498 r->responder_id = ill_get_System_Id(gc, element, "responder-id");
499 r->transaction_type =
500 ill_get_enumerated(gc, element, "transaction-type", 1);
502 r->delivery_address =
503 ill_get_Delivery_Address(gc, element, "delivery-address");
504 r->delivery_service = 0; /* TODO */
505 /* ill_get_Delivery_Service(gc, element, "delivery-service"); */
507 ill_get_Delivery_Address(gc, element, "billing-address");
509 r->num_iLL_service_type = 1;
510 r->iLL_service_type =(ILL_Service_Type **)
511 odr_malloc(o, sizeof(*r->iLL_service_type));
512 *r->iLL_service_type =
513 ill_get_enumerated(gc, element, "ill-service-type",
514 ILL_Service_Type_copy_non_returnable);
516 r->responder_specific_service = 0;
517 r->requester_optional_messages =
518 ill_get_Requester_Optional_Messages_Type(
519 gc, element,"requester-optional-messages");
520 r->search_type = ill_get_Search_Type(gc, element, "search-type");
521 r->num_supply_medium_info_type = 0;
522 r->supply_medium_info_type = 0;
524 r->place_on_hold = ill_get_enumerated(
525 gc, element, "place-on-hold",
526 ILL_Place_On_Hold_Type_according_to_responder_policy);
527 r->client_id = ill_get_Client_Id(gc, element, "client-id");
529 r->item_id = ill_get_Item_Id(gc, element, "item-id");
530 r->supplemental_item_description = 0;
531 r->cost_info_type = 0;
532 r->copyright_compliance =
533 ill_get_ILL_String(gc, element, "copyright-complicance");
534 r->third_party_info_type = 0;
535 r->retry_flag = ill_get_bool(gc, element, "retry-flag", 0);
536 r->forward_flag = ill_get_bool(gc, element, "forward-flag", 0);
537 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
538 r->forward_note = ill_get_ILL_String(gc, element, "forward-note");
539 r->num_iLL_request_extensions = 0;
540 r->iLL_request_extensions = 0;
544 ILL_ItemRequest *ill_get_ItemRequest(
545 struct ill_get_ctl *gc, const char *name, const char *sub)
548 ILL_ItemRequest *r = (ILL_ItemRequest *)odr_malloc(o, sizeof(*r));
551 strcpy(element, name);
554 strcat(element, ",");
555 strcat(element, sub);
557 r->protocol_version_num =
558 ill_get_enumerated(gc, element, "protocol-version-num",
559 ILL_Request_version_2);
561 r->transaction_id = ill_get_Transaction_Id(gc, element, "transaction-id");
562 r->service_date_time =
563 ill_get_Service_Date_Time(gc, element, "service-date-time");
564 r->requester_id = ill_get_System_Id(gc, element, "requester-id");
565 r->responder_id = ill_get_System_Id(gc, element, "responder-id");
566 r->transaction_type =
567 ill_get_enumerated(gc, element, "transaction-type", 1);
569 r->delivery_address =
570 ill_get_Delivery_Address(gc, element, "delivery-address");
571 r->delivery_service = 0; /* TODO */
572 /* ill_get_Delivery_Service(gc, element, "delivery-service"); */
574 ill_get_Delivery_Address(gc, element, "billing-address");
576 r->num_iLL_service_type = 1;
577 r->iLL_service_type =(ILL_Service_Type **)
578 odr_malloc(o, sizeof(*r->iLL_service_type));
579 *r->iLL_service_type =
580 ill_get_enumerated(gc, element, "ill-service-type",
581 ILL_Service_Type_copy_non_returnable);
583 r->responder_specific_service = 0;
584 r->requester_optional_messages =
585 ill_get_Requester_Optional_Messages_Type(
586 gc, element,"requester-optional-messages");
587 r->search_type = ill_get_Search_Type(gc, element, "search-type");
588 r->num_supply_medium_info_type = 0;
589 r->supply_medium_info_type = 0;
591 r->place_on_hold = ill_get_enumerated(
592 gc, element, "place-on-hold",
593 ILL_Place_On_Hold_Type_according_to_responder_policy);
594 r->client_id = ill_get_Client_Id(gc, element, "client-id");
596 r->item_id = ill_get_Item_Id(gc, element, "item-id");
597 r->supplemental_item_description = 0;
598 r->cost_info_type = 0;
599 r->copyright_compliance =
600 ill_get_ILL_String(gc, element, "copyright-complicance");
601 r->third_party_info_type = 0;
602 r->retry_flag = ill_get_bool(gc, element, "retry-flag", 0);
603 r->forward_flag = ill_get_bool(gc, element, "forward-flag", 0);
604 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
605 r->forward_note = ill_get_ILL_String(gc, element, "forward-note");
606 r->num_iLL_request_extensions = 0;
607 r->iLL_request_extensions = 0;
611 ILL_Cancel *ill_get_Cancel(
612 struct ill_get_ctl *gc, const char *name, const char *sub)
615 ILL_Cancel *r = (ILL_Cancel *)odr_malloc(o, sizeof(*r));
618 strcpy(element, name);
621 strcat(element, ",");
622 strcat(element, sub);
624 r->protocol_version_num =
625 ill_get_enumerated(gc, element, "protocol-version-num",
626 ILL_Request_version_2);
628 r->transaction_id = ill_get_Transaction_Id(gc, element, "transaction-id");
629 r->service_date_time =
630 ill_get_Service_Date_Time(gc, element, "service-date-time");
631 r->requester_id = ill_get_System_Id(gc, element, "requester-id");
632 r->responder_id = ill_get_System_Id(gc, element, "responder-id");
633 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
635 r->num_cancel_extensions = 0;
636 r->cancel_extensions = 0;
640 ILL_APDU *ill_get_APDU(
641 struct ill_get_ctl *gc, const char *name, const char *sub)
644 ILL_APDU *r = (ILL_APDU *)odr_malloc(o, sizeof(*r));
648 strcpy(element, name);
649 strcat(element, ",which");
651 v = (gc->f)(gc->clientData, element);
654 if (!strcmp(v, "request"))
656 r->which = ILL_APDU_ILL_Request;
657 r->u.illRequest = ill_get_ILLRequest(gc, name, sub);
659 else if (!strcmp(v, "cancel"))
661 r->which = ILL_APDU_Cancel;
662 r->u.Cancel = ill_get_Cancel(gc, name, sub);
671 * c-file-style: "Stroustrup"
672 * indent-tabs-mode: nil
674 * vim: shiftwidth=4 tabstop=8 expandtab