2 * Copyright (c) 1999-2000, Index Data.
3 * See the file LICENSE for details.
6 * Revision 1.4 2000-02-04 11:01:15 adam
9 * Revision 1.3 2000/01/31 13:15:21 adam
10 * Removed uses of assert(3). Cleanup of ODR. CCL parser update so
11 * that some characters are not surrounded by spaces in resulting term.
14 * Revision 1.2 2000/01/15 09:38:51 adam
15 * Implemented ill_get_ILLRequest. Added some type mappings for ILL protocol.
17 * Revision 1.1 1999/12/16 23:36:19 adam
18 * Implemented ILL protocol. Minor updates ASN.1 compiler.
24 bool_t *ill_get_bool (struct ill_get_ctl *gc, const char *name,
25 const char *sub, int val)
30 bool_t *r = odr_malloc (o, sizeof(*r));
32 strcpy(element, name);
35 strcat (element, ",");
36 strcat (element, sub);
39 v = (gc->f)(gc->clientData, element);
48 int *ill_get_int (struct ill_get_ctl *gc, const char *name,
49 const char *sub, int val)
54 int *r = odr_malloc (o, sizeof(*r));
56 strcpy(element, name);
59 strcat (element, ",");
60 strcat (element, sub);
62 v = (gc->f)(gc->clientData, element);
69 int *ill_get_enumerated (struct ill_get_ctl *gc, const char *name,
70 const char *sub, int val)
72 return ill_get_int(gc, name, sub, val);
75 ILL_String *ill_get_ILL_String (struct ill_get_ctl *gc, const char *name,
78 ILL_String *r = (ILL_String *) odr_malloc (gc->odr, sizeof(*r));
82 strcpy(element, name);
85 strcat (element, ",");
86 strcat (element, sub);
88 v = (gc->f)(gc->clientData, element);
91 r->which = ILL_String_GeneralString;
92 r->u.GeneralString = odr_strdup (gc->odr, v);
97 ILL_ISO_Date *ill_get_ILL_ISO_Date (struct ill_get_ctl *gc, const char *name,
98 const char *sub, const char *val)
103 strcpy(element, name);
106 strcat (element, ",");
107 strcat (element, sub);
109 v = (gc->f)(gc->clientData, element);
114 return odr_strdup (gc->odr, v);
117 ILL_ISO_Time *ill_get_ILL_ISO_Time (struct ill_get_ctl *gc, const char *name,
118 const char *sub, const char *val)
123 strcpy(element, name);
126 strcat (element, ",");
127 strcat (element, sub);
129 v = (gc->f)(gc->clientData, element);
134 return odr_strdup (gc->odr, v);
137 ILL_Person_Or_Institution_Symbol *ill_get_Person_Or_Insitution_Symbol (
138 struct ill_get_ctl *gc, const char *name, const char *sub)
142 ILL_Person_Or_Institution_Symbol *p = odr_malloc (o, sizeof(*p));
144 strcpy(element, name);
147 strcat (element, ",");
148 strcat (element, sub);
150 p->which = ILL_Person_Or_Institution_Symbol_person_symbol;
151 if ((p->u.person_symbol = ill_get_ILL_String (gc, element, "person")))
154 p->which = ILL_Person_Or_Institution_Symbol_institution_symbol;
155 if ((p->u.institution_symbol =
156 ill_get_ILL_String (gc, element, "institution")))
161 static ILL_Name_Of_Person_Or_Institution *ill_get_Name_Of_Person_Or_Institution(
162 struct ill_get_ctl *gc, const char *name, const char *sub)
166 ILL_Name_Of_Person_Or_Institution *p = odr_malloc (o, sizeof(*p));
168 strcpy(element, name);
171 strcat (element, ",");
172 strcat (element, sub);
174 p->which = ILL_Name_Of_Person_Or_Institution_name_of_person;
175 if ((p->u.name_of_person =
176 ill_get_ILL_String (gc, element, "name-of-person")))
179 p->which = ILL_Name_Of_Person_Or_Institution_name_of_institution;
180 if ((p->u.name_of_institution =
181 ill_get_ILL_String (gc, element, "name-of-institution")))
186 ILL_System_Id *ill_get_System_Id(struct ill_get_ctl *gc,
187 const char *name, const char *sub)
193 strcpy(element, name);
196 strcat (element, ",");
197 strcat (element, sub);
199 p = (ILL_System_Id *) odr_malloc (o, sizeof(*p));
200 p->person_or_institution_symbol = ill_get_Person_Or_Insitution_Symbol (
201 gc, element, "person-or-institution-symbol");
202 p->name_of_person_or_institution = ill_get_Name_Of_Person_Or_Institution (
203 gc, element, "name-of-person-or-institution");
207 ILL_Transaction_Id *ill_get_Transaction_Id (struct ill_get_ctl *gc,
208 const char *name, const char *sub)
211 ILL_Transaction_Id *r = (ILL_Transaction_Id *) odr_malloc (o, sizeof(*r));
214 strcpy(element, name);
217 strcat (element, ",");
218 strcat (element, sub);
220 r->initial_requester_id =
221 ill_get_System_Id (gc, element, "initial-requester-id");
222 r->transaction_group_qualifier =
223 ill_get_ILL_String (gc, element, "transaction-group-qualifier");
224 r->transaction_qualifier =
225 ill_get_ILL_String (gc, element, "transaction-qualifier");
226 r->sub_transaction_qualifier =
227 ill_get_ILL_String (gc, element, "sub-transaction-qualifier");
232 ILL_Service_Date_this *ill_get_Service_Date_this (
233 struct ill_get_ctl *gc, const char *name, const char *sub)
236 ILL_Service_Date_this *r =
237 (ILL_Service_Date_this *) odr_malloc (o, sizeof(*r));
240 strcpy(element, name);
243 strcat (element, ",");
244 strcat (element, sub);
246 r->date = ill_get_ILL_ISO_Date (gc, element, "date", "20000101");
247 r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
251 ILL_Service_Date_original *ill_get_Service_Date_original (
252 struct ill_get_ctl *gc, const char *name, const char *sub)
255 ILL_Service_Date_original *r =
256 (ILL_Service_Date_original *) odr_malloc (o, sizeof(*r));
259 strcpy(element, name);
262 strcat (element, ",");
263 strcat (element, sub);
265 r->date = ill_get_ILL_ISO_Date (gc, element, "date", 0);
266 r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
267 if (!r->date && !r->time)
272 ILL_Service_Date_Time *ill_get_Service_Date_Time (
273 struct ill_get_ctl *gc, const char *name, const char *sub)
276 ILL_Service_Date_Time *r =
277 (ILL_Service_Date_Time *) odr_malloc (o, sizeof(*r));
280 strcpy(element, name);
283 strcat (element, ",");
284 strcat (element, sub);
286 r->date_time_of_this_service = ill_get_Service_Date_this (
287 gc, element, "this");
288 r->date_time_of_original_service = ill_get_Service_Date_original (
289 gc, element, "original");
293 ILL_Requester_Optional_Messages_Type *ill_get_Requester_Optional_Messages_Type (
294 struct ill_get_ctl *gc, const char *name, const char *sub)
297 ILL_Requester_Optional_Messages_Type *r =
298 (ILL_Requester_Optional_Messages_Type *) odr_malloc (o, sizeof(*r));
301 strcpy(element, name);
304 strcat (element, ",");
305 strcat (element, sub);
307 r->can_send_RECEIVED = ill_get_bool (gc, element, "can-send-RECEIVED", 0);
308 r->can_send_RETURNED = ill_get_bool (gc, element, "can-send-RETURNED", 0);
309 r->requester_SHIPPED =
310 ill_get_enumerated (gc, element, "requester-SHIPPED", 1);
311 r->requester_CHECKED_IN =
312 ill_get_enumerated (gc, element, "requester-CHECKED-IN", 1);
316 ILL_Item_Id *ill_get_Item_Id (
317 struct ill_get_ctl *gc, const char *name, const char *sub)
320 ILL_Item_Id *r = (ILL_Item_Id *) odr_malloc (o, sizeof(*r));
323 strcpy(element, name);
326 strcat (element, ",");
327 strcat (element, sub);
329 r->item_type = ill_get_enumerated (gc, element, "item-type",
330 ILL_Item_Id_monograph);
331 r->held_medium_type = 0;
332 r->call_number = ill_get_ILL_String(gc, element, "call-number");
333 r->author = ill_get_ILL_String(gc, element, "author");
334 r->title = ill_get_ILL_String(gc, element, "title");
335 r->sub_title = ill_get_ILL_String(gc, element, "sub-title");
336 r->sponsoring_body = ill_get_ILL_String(gc, element, "sponsoring-body");
337 r->place_of_publication =
338 ill_get_ILL_String(gc, element, "place-of-publication");
339 r->publisher = ill_get_ILL_String(gc, element, "publisher");
340 r->series_title_number =
341 ill_get_ILL_String(gc, element, "series-title-number");
342 r->volume_issue = ill_get_ILL_String(gc, element, "volume-issue");
343 r->edition = ill_get_ILL_String(gc, element, "edition");
344 r->publication_date = ill_get_ILL_String(gc, element, "publication-date");
345 r->publication_date_of_component =
346 ill_get_ILL_String(gc, element, "publication-date-of-component");
347 r->author_of_article = ill_get_ILL_String(gc, element,
348 "author-of-article");
349 r->title_of_article = ill_get_ILL_String(gc, element, "title-or-article");
350 r->pagination = ill_get_ILL_String(gc, element, "pagination");
351 r->national_bibliography_no = 0;
352 r->iSBN = ill_get_ILL_String(gc, element, "ISBN");
353 r->iSSN = ill_get_ILL_String(gc, element, "ISSN");
355 r->additional_no_letters =
356 ill_get_ILL_String(gc, element, "additional-no-letters");
357 r->verification_reference_source =
358 ill_get_ILL_String(gc, element, "verification-reference-source");
362 ILL_ItemRequest *ill_get_ItemRequest (
363 struct ill_get_ctl *gc, const char *name, const char *sub)
366 ILL_ItemRequest *r = (ILL_ItemRequest *)odr_malloc(o, sizeof(*r));
371 ILL_Client_Id *ill_get_Client_Id (
372 struct ill_get_ctl *gc, const char *name, const char *sub)
376 ILL_Client_Id *r = (ILL_Client_Id *) odr_malloc(o, sizeof(*r));
378 strcpy(element, name);
381 strcat (element, ",");
382 strcat (element, sub);
384 r->client_name = ill_get_ILL_String (gc, element, "client-name");
385 r->client_status = ill_get_ILL_String (gc, element, "client-status");
386 r->client_identifier = ill_get_ILL_String (gc, element,
387 "client-identifier");
391 ILL_Postal_Address *ill_get_Postal_Address (
392 struct ill_get_ctl *gc, const char *name, const char *sub)
395 ILL_Postal_Address *r =
396 (ILL_Postal_Address *) odr_malloc(o, sizeof(*r));
399 strcpy(element, name);
402 strcat (element, ",");
403 strcat (element, sub);
405 r->name_of_person_or_institution =
406 ill_get_Name_Of_Person_Or_Institution (
407 gc, element, "name-of-person-or-institution");
408 r->extended_postal_delivery_address =
410 gc, element, "extended-postal-delivery-address");
411 r->street_and_number =
412 ill_get_ILL_String (gc, element, "street-and-number");
413 r->city = ill_get_ILL_String (gc, element, "city");
414 r->region = ill_get_ILL_String (gc, element, "region");
415 r->country = ill_get_ILL_String (gc, element, "country");
416 r->postal_code = ill_get_ILL_String (gc, element, "postal-code");
420 ILL_System_Address *ill_get_System_Address (
421 struct ill_get_ctl *gc, const char *name, const char *sub)
424 ILL_System_Address *r =
425 (ILL_System_Address *) odr_malloc(o, sizeof(*r));
428 strcpy(element, name);
431 strcat (element, ",");
432 strcat (element, sub);
434 r->telecom_service_identifier =
435 ill_get_ILL_String (gc, element, "telecom-service-identifier");
436 r->telecom_service_address =
437 ill_get_ILL_String (gc, element, "telecom-service-addreess");
441 ILL_Delivery_Address *ill_get_Delivery_Address (
442 struct ill_get_ctl *gc, const char *name, const char *sub)
445 ILL_Delivery_Address *r =
446 (ILL_Delivery_Address *) odr_malloc(o, sizeof(*r));
449 strcpy(element, name);
452 strcat (element, ",");
453 strcat (element, sub);
456 ill_get_Postal_Address (gc, element, "postal-address");
457 r->electronic_address =
458 ill_get_System_Address (gc, element, "electronic-address");
462 ILL_Search_Type *ill_get_Search_Type (
463 struct ill_get_ctl *gc, const char *name, const char *sub)
466 ILL_Search_Type *r = (ILL_Search_Type *) odr_malloc(o, sizeof(*r));
469 strcpy(element, name);
472 strcat (element, ",");
473 strcat (element, sub);
475 r->level_of_service = ill_get_ILL_String (gc, element, "level-of-service");
476 r->need_before_date = ill_get_ILL_ISO_Date (gc, element,
477 "need-before-date", 0);
478 r->expiry_date = ill_get_ILL_ISO_Date (gc, element, "expiry-date", 0);
479 r->expiry_flag = ill_get_enumerated (gc, element, "expiry-flag", 3);
484 ILL_Request *ill_get_ILLRequest (
485 struct ill_get_ctl *gc, const char *name, const char *sub)
488 ILL_Request *r = (ILL_Request *) odr_malloc(o, sizeof(*r));
491 strcpy(element, name);
494 strcat (element, ",");
495 strcat (element, sub);
497 r->protocol_version_num =
498 ill_get_enumerated (gc, element, "protocol-version-num",
499 ILL_Request_version_2);
501 r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
502 r->service_date_time =
503 ill_get_Service_Date_Time (gc, element, "service-date-time");
504 r->requester_id = ill_get_System_Id (gc, element, "requester-id");
505 r->responder_id = ill_get_System_Id (gc, element, "responder-id");
506 r->transaction_type =
507 ill_get_enumerated(gc, element, "transaction-type", 1);
509 r->delivery_address =
510 ill_get_Delivery_Address (gc, element, "delivery-address");
511 r->delivery_service = 0; /* TODO */
512 /* ill_get_Delivery_Service (gc, element, "delivery-service"); */
514 ill_get_Delivery_Address (gc, element, "billing-address");
516 r->num_iLL_service_type = 1;
517 r->iLL_service_type = (ILL_Service_Type **)
518 odr_malloc (o, sizeof(*r->iLL_service_type));
519 *r->iLL_service_type =
520 ill_get_enumerated (gc, element, "ill-service-type",
521 ILL_Service_Type_copy_non_returnable);
523 r->responder_specific_service = 0;
524 r->requester_optional_messages =
525 ill_get_Requester_Optional_Messages_Type (
526 gc, element,"requester-optional-messages");
527 r->search_type = 0; /* TODO */
528 r->num_supply_medium_info_type = 0;
529 r->supply_medium_info_type = 0;
531 r->place_on_hold = ill_get_enumerated (
532 gc, element, "place-on-hold",
533 ILL_Place_On_Hold_Type_according_to_responder_policy);
534 r->client_id = ill_get_Client_Id (gc, element, "client-id");
536 r->item_id = ill_get_Item_Id (gc, element, "item-id");
537 r->supplemental_item_description = 0;
538 r->cost_info_type = 0;
539 r->copyright_compliance =
540 ill_get_ILL_String(gc, element, "copyright-complicance");
541 r->third_party_info_type = 0;
542 r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0);
543 r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0);
544 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
545 r->forward_note = ill_get_ILL_String(gc, element, "forward-note");
546 r->num_iLL_request_extensions = 0;
547 r->iLL_request_extensions = 0;