Add odr_prepend()
[yaz-moved-to-github.git] / src / ill-get.c
1 /*
2  * Copyright (c) 1999-2001, Index Data.
3  * See the file LICENSE for details.
4  *
5  * $Log: ill-get.c,v $
6  * Revision 1.1  2003-10-27 12:21:30  adam
7  * Source restructure. yaz-marcdump part of installation
8  *
9  * Revision 1.9  2001/03/25 21:55:12  adam
10  * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate.
11  *
12  * Revision 1.8  2001/02/21 13:46:53  adam
13  * C++ fixes.
14  *
15  * Revision 1.7  2001/02/20 11:25:32  adam
16  * Added ill_get_APDU and ill_get_Cancel.
17  *
18  * Revision 1.6  2000/08/10 08:41:26  adam
19  * Fixes for ILL.
20  *
21  * Revision 1.5  2000/02/24 08:52:01  adam
22  * Bug fix.
23  *
24  * Revision 1.4  2000/02/04 11:01:15  adam
25  * Added more elements.
26  *
27  * Revision 1.3  2000/01/31 13:15:21  adam
28  * Removed uses of assert(3). Cleanup of ODR. CCL parser update so
29  * that some characters are not surrounded by spaces in resulting term.
30  * ILL-code updates.
31  *
32  * Revision 1.2  2000/01/15 09:38:51  adam
33  * Implemented ill_get_ILLRequest. Added some type mappings for ILL protocol.
34  *
35  * Revision 1.1  1999/12/16 23:36:19  adam
36  * Implemented ILL protocol. Minor updates ASN.1 compiler.
37  *
38  */
39
40 #include <yaz/ill.h>
41
42 bool_t *ill_get_bool (struct ill_get_ctl *gc, const char *name,
43                       const char *sub, int val)
44 {
45     ODR o = gc->odr;
46     char element[128];
47     const char *v;
48     bool_t *r = (bool_t *) odr_malloc (o, sizeof(*r));
49     
50     strcpy(element, name);
51     if (sub)
52     {
53         strcat (element, ",");
54         strcat (element, sub);
55     }    
56
57     v = (gc->f)(gc->clientData, element);
58     if (v)
59         val = atoi(v);
60     else if (val < 0)
61         return 0;
62     *r = val;
63     return r;
64 }
65
66 int *ill_get_int (struct ill_get_ctl *gc, const char *name,
67                   const char *sub, int val)
68 {
69     ODR o = gc->odr;
70     char element[128];
71     const char *v;
72     
73     strcpy(element, name);
74     if (sub)
75     {
76         strcat (element, ",");
77         strcat (element, sub);
78     }    
79     v = (gc->f)(gc->clientData, element);
80     if (v)
81         val = atoi(v);
82     return odr_intdup(o, val);
83 }
84
85 int *ill_get_enumerated (struct ill_get_ctl *gc, const char *name,
86                          const char *sub, int val)
87 {
88     return ill_get_int(gc, name, sub, val);
89 }
90
91 ILL_String *ill_get_ILL_String_x (struct ill_get_ctl *gc, const char *name,
92                                   const char *sub, const char *vdefault)
93 {
94     ILL_String *r = (ILL_String *) odr_malloc (gc->odr, sizeof(*r));
95     char element[128];
96     const char *v;
97
98     strcpy(element, name);
99     if (sub)
100     {
101         strcat (element, ",");
102         strcat (element, sub);
103     }
104     v = (gc->f)(gc->clientData, element);
105     if (!v)
106         v = vdefault;
107     if (!v)
108         return 0;
109     r->which = ILL_String_GeneralString;
110     r->u.GeneralString = odr_strdup (gc->odr, v);
111     return r;
112 }
113
114 ILL_String *ill_get_ILL_String(struct ill_get_ctl *gc, const char *name,
115                                const char *sub)
116 {
117     return ill_get_ILL_String_x (gc, name, sub, 0);
118 }
119
120 ILL_ISO_Date *ill_get_ILL_ISO_Date (struct ill_get_ctl *gc, const char *name,
121                                     const char *sub, const char *val)
122 {
123     char element[128];
124     const char *v;
125
126     strcpy(element, name);
127     if (sub)
128     {
129         strcat (element, ",");
130         strcat (element, sub);
131     }
132     v = (gc->f)(gc->clientData, element);
133     if (!v)
134         v = val;
135     if (!v)
136         return 0;
137     return odr_strdup (gc->odr, v);
138 }
139
140 ILL_ISO_Time *ill_get_ILL_ISO_Time (struct ill_get_ctl *gc, const char *name,
141                                     const char *sub, const char *val)
142 {
143     char element[128];
144     const char *v;
145
146     strcpy(element, name);
147     if (sub)
148     {
149         strcat (element, ",");
150         strcat (element, sub);
151     }
152     v = (gc->f)(gc->clientData, element);
153     if (!v)
154         v = val;
155     if (!v)
156         return 0;
157     return odr_strdup (gc->odr, v);
158 }
159
160 ILL_Person_Or_Institution_Symbol *ill_get_Person_Or_Insitution_Symbol (
161     struct ill_get_ctl *gc, const char *name, const char *sub)
162 {
163     char element[128];
164     ODR o = gc->odr;
165     ILL_Person_Or_Institution_Symbol *p =
166         (ILL_Person_Or_Institution_Symbol *) odr_malloc (o, sizeof(*p));
167     
168     strcpy(element, name);
169     if (sub)
170     {
171         strcat (element, ",");
172         strcat (element, sub);
173     }
174     p->which = ILL_Person_Or_Institution_Symbol_person_symbol;
175     if ((p->u.person_symbol = ill_get_ILL_String (gc, element, "person")))
176         return p;
177
178     p->which = ILL_Person_Or_Institution_Symbol_institution_symbol;
179     if ((p->u.institution_symbol =
180          ill_get_ILL_String (gc, element, "institution")))
181         return p;
182     return 0;
183 }
184
185 static ILL_Name_Of_Person_Or_Institution *ill_get_Name_Of_Person_Or_Institution(
186     struct ill_get_ctl *gc, const char *name, const char *sub)
187 {
188     char element[128];
189     ODR o = gc->odr;
190     ILL_Name_Of_Person_Or_Institution *p =
191         (ILL_Name_Of_Person_Or_Institution *) odr_malloc (o, sizeof(*p));
192     
193     strcpy(element, name);
194     if (sub)
195     {
196         strcat (element, ",");
197         strcat (element, sub);
198     }
199     p->which = ILL_Name_Of_Person_Or_Institution_name_of_person;
200     if ((p->u.name_of_person =
201          ill_get_ILL_String (gc, element, "name-of-person")))
202         return p;
203
204     p->which = ILL_Name_Of_Person_Or_Institution_name_of_institution;
205     if ((p->u.name_of_institution =
206          ill_get_ILL_String (gc, element, "name-of-institution")))
207         return p;
208     return 0;
209 }
210     
211 ILL_System_Id *ill_get_System_Id(struct ill_get_ctl *gc,
212                                  const char *name, const char *sub)
213 {
214     ODR o = gc->odr;
215     char element[128];
216     ILL_System_Id *p;
217     
218     strcpy(element, name);
219     if (sub)
220     {
221         strcat (element, ",");
222         strcat (element, sub);
223     }
224     p = (ILL_System_Id *) odr_malloc (o, sizeof(*p));
225     p->person_or_institution_symbol = ill_get_Person_Or_Insitution_Symbol (
226         gc, element, "person-or-institution-symbol");
227     p->name_of_person_or_institution = ill_get_Name_Of_Person_Or_Institution (
228         gc, element, "name-of-person-or-institution");
229     return p;
230 }
231
232 ILL_Transaction_Id *ill_get_Transaction_Id (struct ill_get_ctl *gc,
233                                             const char *name, const char *sub)
234 {
235     ODR o = gc->odr;
236     ILL_Transaction_Id *r = (ILL_Transaction_Id *) odr_malloc (o, sizeof(*r));
237     char element[128];
238     
239     strcpy(element, name);
240     if (sub)
241     {
242         strcat (element, ",");
243         strcat (element, sub);
244     }    
245     r->initial_requester_id =
246         ill_get_System_Id (gc, element, "initial-requester-id");
247     r->transaction_group_qualifier =
248         ill_get_ILL_String_x (gc, element, "transaction-group-qualifier", "");
249     r->transaction_qualifier =
250         ill_get_ILL_String_x (gc, element, "transaction-qualifier", "");
251     r->sub_transaction_qualifier =
252         ill_get_ILL_String (gc, element, "sub-transaction-qualifier");
253     return r;
254 }
255
256
257 ILL_Service_Date_this *ill_get_Service_Date_this (
258     struct ill_get_ctl *gc, const char *name, const char *sub)
259 {
260     ODR o = gc->odr;
261     ILL_Service_Date_this *r =
262         (ILL_Service_Date_this *) odr_malloc (o, sizeof(*r));
263     char element[128];
264     
265     strcpy(element, name);
266     if (sub)
267     {
268         strcat (element, ",");
269         strcat (element, sub);
270     }
271     r->date = ill_get_ILL_ISO_Date (gc, element, "date", "20000101");
272     r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
273     return r;
274 }
275
276 ILL_Service_Date_original *ill_get_Service_Date_original (
277     struct ill_get_ctl *gc, const char *name, const char *sub)
278 {
279     ODR o = gc->odr;
280     ILL_Service_Date_original *r =
281         (ILL_Service_Date_original *) odr_malloc (o, sizeof(*r));
282     char element[128];
283     
284     strcpy(element, name);
285     if (sub)
286     {
287         strcat (element, ",");
288         strcat (element, sub);
289     }
290     r->date = ill_get_ILL_ISO_Date (gc, element, "date", 0);
291     r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0);
292     if (!r->date && !r->time)
293         return 0;
294     return r;
295 }
296
297 ILL_Service_Date_Time *ill_get_Service_Date_Time (
298     struct ill_get_ctl *gc, const char *name, const char *sub)
299 {
300     ODR o = gc->odr;
301     ILL_Service_Date_Time *r =
302         (ILL_Service_Date_Time *) odr_malloc (o, sizeof(*r));
303     char element[128];
304     
305     strcpy(element, name);
306     if (sub)
307     {
308         strcat (element, ",");
309         strcat (element, sub);
310     }    
311     r->date_time_of_this_service = ill_get_Service_Date_this (
312         gc, element, "this");
313     r->date_time_of_original_service = ill_get_Service_Date_original (
314         gc, element, "original");
315     return r;
316 }
317
318 ILL_Requester_Optional_Messages_Type *ill_get_Requester_Optional_Messages_Type (
319     struct ill_get_ctl *gc, const char *name, const char *sub)
320 {
321     ODR o = gc->odr;
322     ILL_Requester_Optional_Messages_Type *r =
323         (ILL_Requester_Optional_Messages_Type *) odr_malloc (o, sizeof(*r));
324     char element[128];
325     
326     strcpy(element, name);
327     if (sub)
328     {
329         strcat (element, ",");
330         strcat (element, sub);
331     }
332     r->can_send_RECEIVED = ill_get_bool (gc, element, "can-send-RECEIVED", 0);
333     r->can_send_RETURNED = ill_get_bool (gc, element, "can-send-RETURNED", 0);
334     r->requester_SHIPPED =
335         ill_get_enumerated (gc, element, "requester-SHIPPED", 1);
336     r->requester_CHECKED_IN =
337         ill_get_enumerated (gc, element, "requester-CHECKED-IN", 1);
338     return r;
339 }
340
341 ILL_Item_Id *ill_get_Item_Id (
342     struct ill_get_ctl *gc, const char *name, const char *sub)   
343 {
344     ODR o = gc->odr;
345     ILL_Item_Id *r = (ILL_Item_Id *) odr_malloc (o, sizeof(*r));
346     char element[128];
347     
348     strcpy(element, name);
349     if (sub)
350     {
351         strcat (element, ",");
352         strcat (element, sub);
353     }
354     r->item_type = ill_get_enumerated (gc, element, "item-type",
355                                        ILL_Item_Id_monograph);
356     r->held_medium_type = 0;
357     r->call_number = ill_get_ILL_String(gc, element, "call-number");
358     r->author = ill_get_ILL_String(gc, element, "author");
359     r->title = ill_get_ILL_String(gc, element, "title");
360     r->sub_title = ill_get_ILL_String(gc, element, "sub-title");
361     r->sponsoring_body = ill_get_ILL_String(gc, element, "sponsoring-body");
362     r->place_of_publication =
363         ill_get_ILL_String(gc, element, "place-of-publication");
364     r->publisher = ill_get_ILL_String(gc, element, "publisher");
365     r->series_title_number =
366         ill_get_ILL_String(gc, element, "series-title-number");
367     r->volume_issue = ill_get_ILL_String(gc, element, "volume-issue");
368     r->edition = ill_get_ILL_String(gc, element, "edition");
369     r->publication_date = ill_get_ILL_String(gc, element, "publication-date");
370     r->publication_date_of_component =
371         ill_get_ILL_String(gc, element, "publication-date-of-component");
372     r->author_of_article = ill_get_ILL_String(gc, element,
373                                               "author-of-article");
374     r->title_of_article = ill_get_ILL_String(gc, element, "title-of-article");
375     r->pagination = ill_get_ILL_String(gc, element, "pagination");
376     r->national_bibliography_no = 0;
377     r->iSBN = ill_get_ILL_String(gc, element, "ISBN");
378     r->iSSN = ill_get_ILL_String(gc, element, "ISSN");
379     r->system_no = 0;
380     r->additional_no_letters =
381         ill_get_ILL_String(gc, element, "additional-no-letters");
382     r->verification_reference_source = 
383         ill_get_ILL_String(gc, element, "verification-reference-source");
384     return r;
385 }
386
387
388 ILL_Client_Id *ill_get_Client_Id (
389     struct ill_get_ctl *gc, const char *name, const char *sub)
390 {
391     char element[128];
392     ODR o = gc->odr;
393     ILL_Client_Id *r = (ILL_Client_Id *) odr_malloc(o, sizeof(*r));
394
395     strcpy(element, name);
396     if (sub)
397     {
398         strcat (element, ",");
399         strcat (element, sub);
400     }
401     r->client_name = ill_get_ILL_String (gc, element, "client-name");
402     r->client_status = ill_get_ILL_String (gc, element, "client-status");
403     r->client_identifier = ill_get_ILL_String (gc, element,
404                                                "client-identifier");
405     return r;
406 }
407
408 ILL_Postal_Address *ill_get_Postal_Address (
409     struct ill_get_ctl *gc, const char *name, const char *sub)
410 {
411     ODR o = gc->odr;
412     ILL_Postal_Address *r =
413         (ILL_Postal_Address *) odr_malloc(o, sizeof(*r));
414     char element[128];
415
416     strcpy(element, name);
417     if (sub)
418     {
419         strcat (element, ",");
420         strcat (element, sub);
421     }
422     r->name_of_person_or_institution = 
423         ill_get_Name_Of_Person_Or_Institution (
424             gc, element, "name-of-person-or-institution");
425     r->extended_postal_delivery_address =
426         ill_get_ILL_String (
427             gc, element, "extended-postal-delivery-address");
428     r->street_and_number =
429         ill_get_ILL_String (gc, element, "street-and-number");
430     r->post_office_box =
431         ill_get_ILL_String (gc, element, "post-office-box");
432     r->city = ill_get_ILL_String (gc, element, "city");
433     r->region = ill_get_ILL_String (gc, element, "region");
434     r->country = ill_get_ILL_String (gc, element, "country");
435     r->postal_code = ill_get_ILL_String (gc, element, "postal-code");
436     return r;
437 }
438
439 ILL_System_Address *ill_get_System_Address (
440     struct ill_get_ctl *gc, const char *name, const char *sub)
441 {
442     ODR o = gc->odr;
443     ILL_System_Address *r =
444         (ILL_System_Address *) odr_malloc(o, sizeof(*r));
445     char element[128];
446     
447     strcpy(element, name);
448     if (sub)
449     {
450         strcat (element, ",");
451         strcat (element, sub);
452     }
453     r->telecom_service_identifier =
454         ill_get_ILL_String (gc, element, "telecom-service-identifier");
455     r->telecom_service_address =
456         ill_get_ILL_String (gc, element, "telecom-service-addreess");
457     return r;
458 }
459
460 ILL_Delivery_Address *ill_get_Delivery_Address (
461     struct ill_get_ctl *gc, const char *name, const char *sub)
462 {
463     ODR o = gc->odr;
464     ILL_Delivery_Address *r =
465         (ILL_Delivery_Address *) odr_malloc(o, sizeof(*r));
466     char element[128];
467     
468     strcpy(element, name);
469     if (sub)
470     {
471         strcat (element, ",");
472         strcat (element, sub);
473     }
474     r->postal_address =
475         ill_get_Postal_Address (gc, element, "postal-address");
476     r->electronic_address =
477         ill_get_System_Address (gc, element, "electronic-address");
478     return r;
479 }
480
481 ILL_Search_Type *ill_get_Search_Type (
482     struct ill_get_ctl *gc, const char *name, const char *sub)
483 {
484     ODR o = gc->odr;
485     ILL_Search_Type *r = (ILL_Search_Type *) odr_malloc(o, sizeof(*r));
486     char element[128];
487     
488     strcpy(element, name);
489     if (sub)
490     {
491         strcat (element, ",");
492         strcat (element, sub);
493     }
494     r->level_of_service = ill_get_ILL_String (gc, element, "level-of-service");
495     r->need_before_date = ill_get_ILL_ISO_Date (gc, element,
496                                                 "need-before-date", 0);
497     r->expiry_date = ill_get_ILL_ISO_Date (gc, element, "expiry-date", 0);
498     r->expiry_flag = ill_get_enumerated (gc, element, "expiry-flag", 3);
499                                          
500     return r;
501 }
502
503 ILL_Request *ill_get_ILLRequest (
504     struct ill_get_ctl *gc, const char *name, const char *sub)
505 {
506     ODR o = gc->odr;
507     ILL_Request *r = (ILL_Request *) odr_malloc(o, sizeof(*r));
508     char element[128];
509     
510     strcpy(element, name);
511     if (sub)
512     {
513         strcat (element, ",");
514         strcat (element, sub);
515     }
516     r->protocol_version_num =
517         ill_get_enumerated (gc, element, "protocol-version-num", 
518                             ILL_Request_version_2);
519     
520     r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
521     r->service_date_time =
522         ill_get_Service_Date_Time (gc, element, "service-date-time");
523     r->requester_id = ill_get_System_Id (gc, element, "requester-id");
524     r->responder_id = ill_get_System_Id (gc, element, "responder-id");
525     r->transaction_type =
526         ill_get_enumerated(gc, element, "transaction-type", 1);
527
528     r->delivery_address =
529         ill_get_Delivery_Address (gc, element, "delivery-address");
530     r->delivery_service = 0; /* TODO */
531     /* ill_get_Delivery_Service (gc, element, "delivery-service"); */
532     r->billing_address =
533         ill_get_Delivery_Address (gc, element, "billing-address");
534
535     r->num_iLL_service_type = 1;
536     r->iLL_service_type = (ILL_Service_Type **)
537         odr_malloc (o, sizeof(*r->iLL_service_type));
538     *r->iLL_service_type =
539         ill_get_enumerated (gc, element, "ill-service-type",
540                             ILL_Service_Type_copy_non_returnable);
541
542     r->responder_specific_service = 0;
543     r->requester_optional_messages =
544         ill_get_Requester_Optional_Messages_Type (
545             gc, element,"requester-optional-messages");
546     r->search_type = ill_get_Search_Type(gc, element, "search-type");
547     r->num_supply_medium_info_type = 0;
548     r->supply_medium_info_type = 0;
549
550     r->place_on_hold = ill_get_enumerated (
551         gc, element, "place-on-hold", 
552         ILL_Place_On_Hold_Type_according_to_responder_policy);
553     r->client_id = ill_get_Client_Id (gc, element, "client-id");
554                            
555     r->item_id = ill_get_Item_Id (gc, element, "item-id");
556     r->supplemental_item_description = 0;
557     r->cost_info_type = 0;
558     r->copyright_compliance =
559         ill_get_ILL_String(gc, element, "copyright-complicance");
560     r->third_party_info_type = 0;
561     r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0);
562     r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0);
563     r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
564     r->forward_note = ill_get_ILL_String(gc, element, "forward-note");
565     r->num_iLL_request_extensions = 0;
566     r->iLL_request_extensions = 0;
567     return r;
568 }
569
570 ILL_ItemRequest *ill_get_ItemRequest (
571     struct ill_get_ctl *gc, const char *name, const char *sub)
572 {
573     ODR o = gc->odr;
574     ILL_ItemRequest *r = (ILL_ItemRequest *)odr_malloc(o, sizeof(*r));
575     char element[128];
576     
577     strcpy(element, name);
578     if (sub)
579     {
580         strcat (element, ",");
581         strcat (element, sub);
582     }
583     r->protocol_version_num =
584         ill_get_enumerated (gc, element, "protocol-version-num", 
585                             ILL_Request_version_2);
586     
587     r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
588     r->service_date_time =
589         ill_get_Service_Date_Time (gc, element, "service-date-time");
590     r->requester_id = ill_get_System_Id (gc, element, "requester-id");
591     r->responder_id = ill_get_System_Id (gc, element, "responder-id");
592     r->transaction_type =
593         ill_get_enumerated(gc, element, "transaction-type", 1);
594
595     r->delivery_address =
596         ill_get_Delivery_Address (gc, element, "delivery-address");
597     r->delivery_service = 0; /* TODO */
598     /* ill_get_Delivery_Service (gc, element, "delivery-service"); */
599     r->billing_address =
600         ill_get_Delivery_Address (gc, element, "billing-address");
601
602     r->num_iLL_service_type = 1;
603     r->iLL_service_type = (ILL_Service_Type **)
604         odr_malloc (o, sizeof(*r->iLL_service_type));
605     *r->iLL_service_type =
606         ill_get_enumerated (gc, element, "ill-service-type",
607                             ILL_Service_Type_copy_non_returnable);
608
609     r->responder_specific_service = 0;
610     r->requester_optional_messages =
611         ill_get_Requester_Optional_Messages_Type (
612             gc, element,"requester-optional-messages");
613     r->search_type = ill_get_Search_Type(gc, element, "search-type");
614     r->num_supply_medium_info_type = 0;
615     r->supply_medium_info_type = 0;
616
617     r->place_on_hold = ill_get_enumerated (
618         gc, element, "place-on-hold", 
619         ILL_Place_On_Hold_Type_according_to_responder_policy);
620     r->client_id = ill_get_Client_Id (gc, element, "client-id");
621                            
622     r->item_id = ill_get_Item_Id (gc, element, "item-id");
623     r->supplemental_item_description = 0;
624     r->cost_info_type = 0;
625     r->copyright_compliance =
626         ill_get_ILL_String(gc, element, "copyright-complicance");
627     r->third_party_info_type = 0;
628     r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0);
629     r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0);
630     r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
631     r->forward_note = ill_get_ILL_String(gc, element, "forward-note");
632     r->num_iLL_request_extensions = 0;
633     r->iLL_request_extensions = 0;
634     return r;
635 }
636
637 ILL_Cancel *ill_get_Cancel (
638     struct ill_get_ctl *gc, const char *name, const char *sub)
639 {
640     ODR o = gc->odr;
641     ILL_Cancel *r = (ILL_Cancel *)odr_malloc(o, sizeof(*r));
642     char element[128];
643     
644     strcpy(element, name);
645     if (sub)
646     {
647         strcat (element, ",");
648         strcat (element, sub);
649     }
650     r->protocol_version_num =
651         ill_get_enumerated (gc, element, "protocol-version-num", 
652                             ILL_Request_version_2);
653     
654     r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id");
655     r->service_date_time =
656         ill_get_Service_Date_Time (gc, element, "service-date-time");
657     r->requester_id = ill_get_System_Id (gc, element, "requester-id");
658     r->responder_id = ill_get_System_Id (gc, element, "responder-id");
659     r->requester_note = ill_get_ILL_String(gc, element, "requester-note");
660
661     r->num_cancel_extensions = 0;
662     r->cancel_extensions = 0;
663     return r;
664 }
665
666 ILL_APDU *ill_get_APDU (
667     struct ill_get_ctl *gc, const char *name, const char *sub)
668 {
669     ODR o = gc->odr;
670     ILL_APDU *r = (ILL_APDU *)odr_malloc(o, sizeof(*r));
671     char element[128];
672     const char *v;
673
674     strcpy (element, name);
675     strcat (element, ",which");
676
677     v = (gc->f)(gc->clientData, element);
678     if (!v)
679         v = "request";
680     if (!strcmp (v, "request"))
681     {
682         r->which = ILL_APDU_ILL_Request;
683         r->u.illRequest = ill_get_ILLRequest(gc, name, sub);
684     }
685     else if (!strcmp (v, "cancel"))
686     {
687         r->which = ILL_APDU_Cancel;
688         r->u.Cancel = ill_get_Cancel(gc, name, sub);
689     }
690     else
691         return 0;
692     return r;
693 }