2 * Copyright (c) 1999-2000, Index Data.
3 * See the file LICENSE for details.
6 * Revision 1.5 2000-02-24 08:52:01 adam
9 * Revision 1.4 2000/02/04 11:01:15 adam
10 * Added more elements.
12 * Revision 1.3 2000/01/31 13:15:21 adam
13 * Removed uses of assert(3). Cleanup of ODR. CCL parser update so
14 * that some characters are not surrounded by spaces in resulting term.
17 * Revision 1.2 2000/01/15 09:38:51 adam
18 * Implemented ill_get_ILLRequest. Added some type mappings for ILL protocol.
20 * Revision 1.1 1999/12/16 23:36:19 adam
21 * Implemented ILL protocol. Minor updates ASN.1 compiler.
27 bool_t *ill_get_bool (struct ill_get_ctl *gc, const char *name,
28 const char *sub, int val)
33 bool_t *r = odr_malloc (o, sizeof(*r));
35 strcpy(element, name);
38 strcat (element, ",");
39 strcat (element, sub);
42 v = (gc->f)(gc->clientData, element);
51 int *ill_get_int (struct ill_get_ctl *gc, const char *name,
52 const char *sub, int val)
57 int *r = odr_malloc (o, sizeof(*r));
59 strcpy(element, name);
62 strcat (element, ",");
63 strcat (element, sub);
65 v = (gc->f)(gc->clientData, element);
72 int *ill_get_enumerated (struct ill_get_ctl *gc, const char *name,
73 const char *sub, int val)
75 return ill_get_int(gc, name, sub, val);
78 ILL_String *ill_get_ILL_String (struct ill_get_ctl *gc, const char *name,
81 ILL_String *r = (ILL_String *) odr_malloc (gc->odr, sizeof(*r));
85 strcpy(element, name);
88 strcat (element, ",");
89 strcat (element, sub);
91 v = (gc->f)(gc->clientData, element);
94 r->which = ILL_String_GeneralString;
95 r->u.GeneralString = odr_strdup (gc->odr, v);
100 ILL_ISO_Date *ill_get_ILL_ISO_Date (struct ill_get_ctl *gc, const char *name,
101 const char *sub, const char *val)
106 strcpy(element, name);
109 strcat (element, ",");
110 strcat (element, sub);
112 v = (gc->f)(gc->clientData, element);
117 return odr_strdup (gc->odr, v);
120 ILL_ISO_Time *ill_get_ILL_ISO_Time (struct ill_get_ctl *gc, const char *name,
121 const char *sub, const char *val)
126 strcpy(element, name);
129 strcat (element, ",");
130 strcat (element, sub);
132 v = (gc->f)(gc->clientData, element);
137 return odr_strdup (gc->odr, v);
140 ILL_Person_Or_Institution_Symbol *ill_get_Person_Or_Insitution_Symbol (
141 struct ill_get_ctl *gc, const char *name, const char *sub)
145 ILL_Person_Or_Institution_Symbol *p = odr_malloc (o, sizeof(*p));
147 strcpy(element, name);
150 strcat (element, ",");
151 strcat (element, sub);
153 p->which = ILL_Person_Or_Institution_Symbol_person_symbol;
154 if ((p->u.person_symbol = ill_get_ILL_String (gc, element, "person")))
157 p->which = ILL_Person_Or_Institution_Symbol_institution_symbol;
158 if ((p->u.institution_symbol =
159 ill_get_ILL_String (gc, element, "institution")))
164 static ILL_Name_Of_Person_Or_Institution *ill_get_Name_Of_Person_Or_Institution(
165 struct ill_get_ctl *gc, const char *name, const char *sub)
169 ILL_Name_Of_Person_Or_Institution *p = odr_malloc (o, sizeof(*p));
171 strcpy(element, name);
174 strcat (element, ",");
175 strcat (element, sub);
177 p->which = ILL_Name_Of_Person_Or_Institution_name_of_person;
178 if ((p->u.name_of_person =
179 ill_get_ILL_String (gc, element, "name-of-person")))
182 p->which = ILL_Name_Of_Person_Or_Institution_name_of_institution;
183 if ((p->u.name_of_institution =
184 ill_get_ILL_String (gc, element, "name-of-institution")))
189 ILL_System_Id *ill_get_System_Id(struct ill_get_ctl *gc,
190 const char *name, const char *sub)
196 strcpy(element, name);
199 strcat (element, ",");
200 strcat (element, sub);
202 p = (ILL_System_Id *) odr_malloc (o, sizeof(*p));
203 p->person_or_institution_symbol = ill_get_Person_Or_Insitution_Symbol (
204 gc, element, "person-or-institution-symbol");
205 p->name_of_person_or_institution = ill_get_Name_Of_Person_Or_Institution (
206 gc, element, "name-of-person-or-institution");
210 ILL_Transaction_Id *ill_get_Transaction_Id (struct ill_get_ctl *gc,
211 const char *name, const char *sub)
214 ILL_Transaction_Id *r = (ILL_Transaction_Id *) odr_malloc (o, sizeof(*r));
217 strcpy(element, name);
220 strcat (element, ",");
221 strcat (element, sub);
223 r->initial_requester_id =
224 ill_get_System_Id (gc, element, "initial-requester-id");
225 r->transaction_group_qualifier =
226 ill_get_ILL_String (gc, element, "transaction-group-qualifier");
227 r->transaction_qualifier =
228 ill_get_ILL_String (gc, element, "transaction-qualifier");
229 r->sub_transaction_qualifier =
230 ill_get_ILL_String (gc, element, "sub-transaction-qualifier");
235 ILL_Service_Date_this *ill_get_Service_Date_this (
236 struct ill_get_ctl *gc, const char *name, const char *sub)
239 ILL_Service_Date_this *r =
240 (ILL_Service_Date_this *) odr_malloc (o, sizeof(*r));
243 strcpy(element, name);
246 strcat (element, ",");
247 strcat (element, sub);
249 r->date = ill_get_ILL_ISO_Date (gc, element, "date", "20000101");
250 r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
254 ILL_Service_Date_original *ill_get_Service_Date_original (
255 struct ill_get_ctl *gc, const char *name, const char *sub)
258 ILL_Service_Date_original *r =
259 (ILL_Service_Date_original *) odr_malloc (o, sizeof(*r));
262 strcpy(element, name);
265 strcat (element, ",");
266 strcat (element, sub);
268 r->date = ill_get_ILL_ISO_Date (gc, element, "date", 0);
269 r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
270 if (!r->date && !r->time)
275 ILL_Service_Date_Time *ill_get_Service_Date_Time (
276 struct ill_get_ctl *gc, const char *name, const char *sub)
279 ILL_Service_Date_Time *r =
280 (ILL_Service_Date_Time *) odr_malloc (o, sizeof(*r));
283 strcpy(element, name);
286 strcat (element, ",");
287 strcat (element, sub);
289 r->date_time_of_this_service = ill_get_Service_Date_this (
290 gc, element, "this");
291 r->date_time_of_original_service = ill_get_Service_Date_original (
292 gc, element, "original");
296 ILL_Requester_Optional_Messages_Type *ill_get_Requester_Optional_Messages_Type (
297 struct ill_get_ctl *gc, const char *name, const char *sub)
300 ILL_Requester_Optional_Messages_Type *r =
301 (ILL_Requester_Optional_Messages_Type *) odr_malloc (o, sizeof(*r));
304 strcpy(element, name);
307 strcat (element, ",");
308 strcat (element, sub);
310 r->can_send_RECEIVED = ill_get_bool (gc, element, "can-send-RECEIVED", 0);
311 r->can_send_RETURNED = ill_get_bool (gc, element, "can-send-RETURNED", 0);
312 r->requester_SHIPPED =
313 ill_get_enumerated (gc, element, "requester-SHIPPED", 1);
314 r->requester_CHECKED_IN =
315 ill_get_enumerated (gc, element, "requester-CHECKED-IN", 1);
319 ILL_Item_Id *ill_get_Item_Id (
320 struct ill_get_ctl *gc, const char *name, const char *sub)
323 ILL_Item_Id *r = (ILL_Item_Id *) odr_malloc (o, sizeof(*r));
326 strcpy(element, name);
329 strcat (element, ",");
330 strcat (element, sub);
332 r->item_type = ill_get_enumerated (gc, element, "item-type",
333 ILL_Item_Id_monograph);
334 r->held_medium_type = 0;
335 r->call_number = ill_get_ILL_String(gc, element, "call-number");
336 r->author = ill_get_ILL_String(gc, element, "author");
337 r->title = ill_get_ILL_String(gc, element, "title");
338 r->sub_title = ill_get_ILL_String(gc, element, "sub-title");
339 r->sponsoring_body = ill_get_ILL_String(gc, element, "sponsoring-body");
340 r->place_of_publication =
341 ill_get_ILL_String(gc, element, "place-of-publication");
342 r->publisher = ill_get_ILL_String(gc, element, "publisher");
343 r->series_title_number =
344 ill_get_ILL_String(gc, element, "series-title-number");
345 r->volume_issue = ill_get_ILL_String(gc, element, "volume-issue");
346 r->edition = ill_get_ILL_String(gc, element, "edition");
347 r->publication_date = ill_get_ILL_String(gc, element, "publication-date");
348 r->publication_date_of_component =
349 ill_get_ILL_String(gc, element, "publication-date-of-component");
350 r->author_of_article = ill_get_ILL_String(gc, element,
351 "author-of-article");
352 r->title_of_article = ill_get_ILL_String(gc, element, "title-or-article");
353 r->pagination = ill_get_ILL_String(gc, element, "pagination");
354 r->national_bibliography_no = 0;
355 r->iSBN = ill_get_ILL_String(gc, element, "ISBN");
356 r->iSSN = ill_get_ILL_String(gc, element, "ISSN");
358 r->additional_no_letters =
359 ill_get_ILL_String(gc, element, "additional-no-letters");
360 r->verification_reference_source =
361 ill_get_ILL_String(gc, element, "verification-reference-source");
365 ILL_ItemRequest *ill_get_ItemRequest (
366 struct ill_get_ctl *gc, const char *name, const char *sub)
369 ILL_ItemRequest *r = (ILL_ItemRequest *)odr_malloc(o, sizeof(*r));
374 ILL_Client_Id *ill_get_Client_Id (
375 struct ill_get_ctl *gc, const char *name, const char *sub)
379 ILL_Client_Id *r = (ILL_Client_Id *) odr_malloc(o, sizeof(*r));
381 strcpy(element, name);
384 strcat (element, ",");
385 strcat (element, sub);
387 r->client_name = ill_get_ILL_String (gc, element, "client-name");
388 r->client_status = ill_get_ILL_String (gc, element, "client-status");
389 r->client_identifier = ill_get_ILL_String (gc, element,
390 "client-identifier");
394 ILL_Postal_Address *ill_get_Postal_Address (
395 struct ill_get_ctl *gc, const char *name, const char *sub)
398 ILL_Postal_Address *r =
399 (ILL_Postal_Address *) odr_malloc(o, sizeof(*r));
402 strcpy(element, name);
405 strcat (element, ",");
406 strcat (element, sub);
408 r->name_of_person_or_institution =
409 ill_get_Name_Of_Person_Or_Institution (
410 gc, element, "name-of-person-or-institution");
411 r->extended_postal_delivery_address =
413 gc, element, "extended-postal-delivery-address");
414 r->street_and_number =
415 ill_get_ILL_String (gc, element, "street-and-number");
417 ill_get_ILL_String (gc, element, "post-office-box");
418 r->city = ill_get_ILL_String (gc, element, "city");
419 r->region = ill_get_ILL_String (gc, element, "region");
420 r->country = ill_get_ILL_String (gc, element, "country");
421 r->postal_code = ill_get_ILL_String (gc, element, "postal-code");
425 ILL_System_Address *ill_get_System_Address (
426 struct ill_get_ctl *gc, const char *name, const char *sub)
429 ILL_System_Address *r =
430 (ILL_System_Address *) odr_malloc(o, sizeof(*r));
433 strcpy(element, name);
436 strcat (element, ",");
437 strcat (element, sub);
439 r->telecom_service_identifier =
440 ill_get_ILL_String (gc, element, "telecom-service-identifier");
441 r->telecom_service_address =
442 ill_get_ILL_String (gc, element, "telecom-service-addreess");
446 ILL_Delivery_Address *ill_get_Delivery_Address (
447 struct ill_get_ctl *gc, const char *name, const char *sub)
450 ILL_Delivery_Address *r =
451 (ILL_Delivery_Address *) odr_malloc(o, sizeof(*r));
454 strcpy(element, name);
457 strcat (element, ",");
458 strcat (element, sub);
461 ill_get_Postal_Address (gc, element, "postal-address");
462 r->electronic_address =
463 ill_get_System_Address (gc, element, "electronic-address");
467 ILL_Search_Type *ill_get_Search_Type (
468 struct ill_get_ctl *gc, const char *name, const char *sub)
471 ILL_Search_Type *r = (ILL_Search_Type *) odr_malloc(o, sizeof(*r));
474 strcpy(element, name);
477 strcat (element, ",");
478 strcat (element, sub);
480 r->level_of_service = ill_get_ILL_String (gc, element, "level-of-service");
481 r->need_before_date = ill_get_ILL_ISO_Date (gc, element,
482 "need-before-date", 0);
483 r->expiry_date = ill_get_ILL_ISO_Date (gc, element, "expiry-date", 0);
484 r->expiry_flag = ill_get_enumerated (gc, element, "expiry-flag", 3);
489 ILL_Request *ill_get_ILLRequest (
490 struct ill_get_ctl *gc, const char *name, const char *sub)
493 ILL_Request *r = (ILL_Request *) odr_malloc(o, sizeof(*r));
496 strcpy(element, name);
499 strcat (element, ",");
500 strcat (element, sub);
502 r->protocol_version_num =
503 ill_get_enumerated (gc, element, "protocol-version-num",
504 ILL_Request_version_2);
506 r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
507 r->service_date_time =
508 ill_get_Service_Date_Time (gc, element, "service-date-time");
509 r->requester_id = ill_get_System_Id (gc, element, "requester-id");
510 r->responder_id = ill_get_System_Id (gc, element, "responder-id");
511 r->transaction_type =
512 ill_get_enumerated(gc, element, "transaction-type", 1);
514 r->delivery_address =
515 ill_get_Delivery_Address (gc, element, "delivery-address");
516 r->delivery_service = 0; /* TODO */
517 /* ill_get_Delivery_Service (gc, element, "delivery-service"); */
519 ill_get_Delivery_Address (gc, element, "billing-address");
521 r->num_iLL_service_type = 1;
522 r->iLL_service_type = (ILL_Service_Type **)
523 odr_malloc (o, sizeof(*r->iLL_service_type));
524 *r->iLL_service_type =
525 ill_get_enumerated (gc, element, "ill-service-type",
526 ILL_Service_Type_copy_non_returnable);
528 r->responder_specific_service = 0;
529 r->requester_optional_messages =
530 ill_get_Requester_Optional_Messages_Type (
531 gc, element,"requester-optional-messages");
532 r->search_type = 0; /* TODO */
533 r->num_supply_medium_info_type = 0;
534 r->supply_medium_info_type = 0;
536 r->place_on_hold = ill_get_enumerated (
537 gc, element, "place-on-hold",
538 ILL_Place_On_Hold_Type_according_to_responder_policy);
539 r->client_id = ill_get_Client_Id (gc, element, "client-id");
541 r->item_id = ill_get_Item_Id (gc, element, "item-id");
542 r->supplemental_item_description = 0;
543 r->cost_info_type = 0;
544 r->copyright_compliance =
545 ill_get_ILL_String(gc, element, "copyright-complicance");
546 r->third_party_info_type = 0;
547 r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0);
548 r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0);
549 r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
550 r->forward_note = ill_get_ILL_String(gc, element, "forward-note");
551 r->num_iLL_request_extensions = 0;
552 r->iLL_request_extensions = 0;