Implemented ill_get_ILLRequest. Added some type mappings for ILL protocol.
[yaz-moved-to-github.git] / ill / ill-get.c
1 /*
2  * Copyright (c) 1999-2000, Index Data.
3  * See the file LICENSE for details.
4  *
5  * $Log: ill-get.c,v $
6  * Revision 1.2  2000-01-15 09:38:51  adam
7  * Implemented ill_get_ILLRequest. Added some type mappings for ILL protocol.
8  *
9  * Revision 1.1  1999/12/16 23:36:19  adam
10  * Implemented ILL protocol. Minor updates ASN.1 compiler.
11  *
12  */
13
14 #include <yaz/ill.h>
15
16 ILL_String *ill_get_ILL_String (ODR o, const char *str)
17 {
18     ILL_String *r = (ILL_String *) odr_malloc (o, sizeof(*r));
19
20     r->which = ILL_String_GeneralString;
21     r->u.GeneralString = odr_strdup (o, str);
22     return r;
23 }
24
25 ILL_Transaction_Id *ill_get_Transaction_Id (ODR o)
26 {
27     ILL_Transaction_Id *r = (ILL_Transaction_Id *) odr_malloc (o, sizeof(*r));
28     
29     r->initial_requester_id = 0;
30     r->transaction_group_qualifier = ill_get_ILL_String (o, "group");
31     r->transaction_qualifier = ill_get_ILL_String (o, "qual");
32     r->sub_transaction_qualifier = 0;
33     return r;
34 }
35
36
37 ILL_Service_Date_this *ill_get_Service_Date_this (ODR o)
38 {
39     ILL_Service_Date_this *r =
40         (ILL_Service_Date_this *) odr_malloc (o, sizeof(*r));
41     r->date = odr_strdup (o, "14012000");
42     r->time = 0;
43     return r;
44 }
45
46 ILL_Service_Date_Time *ill_get_Service_Date_Time (ODR o)
47 {
48     ILL_Service_Date_Time *r =
49         (ILL_Service_Date_Time *) odr_malloc (o, sizeof(*r));
50     r->date_time_of_this_service = ill_get_Service_Date_this (o);
51     r->date_time_of_original_service = 0;
52     return r;
53 }
54
55 ILL_Transaction_Type *ill_get_Transaction_Type (ODR o)
56 {
57     ILL_Transaction_Type *r =
58         (ILL_Transaction_Type *) odr_malloc (o, sizeof(*r));
59     *r = 1;
60     return r;
61 }
62
63
64 bool_t *ill_get_bool (ODR o, int val)
65 {
66     bool_t *r = odr_malloc (o, sizeof(*r));
67     *r = val;
68     return r;
69 }
70
71 int *ill_get_enumerated (ODR o, int val)
72 {
73     int *r = odr_malloc (o, sizeof(*r));
74     *r = val;
75     return r;
76 }
77
78 int *ill_get_int (ODR o, int val)
79 {
80     return ill_get_enumerated (o, val);
81 }
82
83
84 ILL_Requester_Optional_Messages_Type *ill_get_Requester_Optional_Messages_Type (ODR o)
85 {
86     ILL_Requester_Optional_Messages_Type *r =
87         (ILL_Requester_Optional_Messages_Type *) odr_malloc (o, sizeof(*r));
88     r->can_send_RECEIVED = ill_get_bool (o, 0);
89     r->can_send_RETURNED = ill_get_bool (o, 0);
90     r->requester_SHIPPED =
91         ill_get_enumerated (o, ILL_Requester_Optional_Messages_Type_requires);
92     r->requester_CHECKED_IN =
93         ill_get_enumerated (o, ILL_Requester_Optional_Messages_Type_requires);
94     return r;
95 }
96
97 ILL_Item_Id *ill_get_Item_Id (ODR o)
98 {
99     ILL_Item_Id *r = (ILL_Item_Id *) odr_malloc (o, sizeof(*r));
100
101     r->item_type = ill_get_enumerated (o, ILL_Item_Id_monograph);
102     r->held_medium_type = 0;
103     r->call_number = 0;
104     r->author = 0;
105     r->title = 0;
106     r->sub_title = 0;
107     r->sponsoring_body = 0;
108     r->place_of_publication = 0;
109     r->publisher = 0;
110     r->series_title_number = 0;
111     r->volume_issue = 0;
112     r->edition = 0;
113     r->publication_date = 0;
114     r->publication_date_of_component = 0;
115     r->author_of_article = 0;
116     r->title_of_article = 0;
117     r->pagination = 0;
118     r->national_bibliography_no = 0;
119     r->iSBN = 0;
120     r->iSSN = 0;
121     r->system_no = 0;
122     r->additional_no_letters = 0;
123     r->verification_reference_source = 0;
124     return r;
125 }
126
127 ILL_ItemRequest *ill_get_ItemRequest (ODR o)
128 {
129     ILL_ItemRequest *r = (ILL_ItemRequest *)odr_malloc(o, sizeof(*r));
130     
131     r->protocol_version_num = ill_get_enumerated (o, ILL_Request_version_2);
132
133     r->transaction_id = 0;
134     r->service_date_time = 0;
135     r->requester_id = 0;
136     r->responder_id = 0;
137     r->transaction_type = ill_get_Transaction_Type (o);
138     r->delivery_address = 0;
139     r->delivery_service = 0;
140     r->billing_address = 0;
141
142     r->num_iLL_service_type = 1;
143     r->iLL_service_type = (ILL_Service_Type **)
144         odr_malloc (o, sizeof(*r->iLL_service_type));
145     *r->iLL_service_type =
146         ill_get_enumerated (o, ILL_Service_Type_copy_non_returnable);
147
148     r->responder_specific_service = 0;
149     r->requester_optional_messages = 0;
150     r->search_type = 0;
151     r->num_supply_medium_info_type = 0;
152     r->supply_medium_info_type = 0;
153
154     r->place_on_hold = (int*) odr_malloc(o, sizeof(int));
155     *r->place_on_hold = ILL_Place_On_Hold_Type_according_to_responder_policy;
156
157     r->client_id = 0;
158     r->item_id = 0;
159     r->supplemental_item_description = 0;
160     r->cost_info_type = 0;
161     r->copyright_compliance = 0;
162     r->third_party_info_type = 0;
163     r->retry_flag = ill_get_bool (o, 0);
164     r->forward_flag = ill_get_bool (o, 0);
165     r->requester_note = 0;
166     r->forward_note = 0;
167     r->num_iLL_request_extensions = 0;
168     r->iLL_request_extensions = 0;
169     return r;
170 }
171
172 ILL_Request *ill_get_ILLRequest (ODR o)
173 {
174     ILL_Request *r = (ILL_Request *) odr_malloc(o, sizeof(*r));
175
176     r->protocol_version_num = ill_get_enumerated (o, ILL_Request_version_2);
177
178     r->transaction_id = ill_get_Transaction_Id (o);
179
180     r->service_date_time = ill_get_Service_Date_Time (o);
181     r->requester_id = 0;
182     r->responder_id = 0;
183     r->transaction_type = ill_get_Transaction_Type(o);
184     r->delivery_address = 0;
185     r->delivery_service = 0;
186     r->billing_address = 0;
187
188     r->num_iLL_service_type = 1;
189     r->iLL_service_type = (ILL_Service_Type **)
190         odr_malloc (o, sizeof(*r->iLL_service_type));
191     *r->iLL_service_type =
192         ill_get_enumerated (o, ILL_Service_Type_copy_non_returnable);
193
194     r->responder_specific_service = 0;
195     r->requester_optional_messages =
196         ill_get_Requester_Optional_Messages_Type (o);;
197     r->search_type = 0;
198     r->num_supply_medium_info_type = 0;
199     r->supply_medium_info_type = 0;
200
201     r->place_on_hold = (int*) odr_malloc(o, sizeof(int));
202     *r->place_on_hold = ILL_Place_On_Hold_Type_according_to_responder_policy;
203
204     r->client_id = 0;
205     r->item_id = ill_get_Item_Id (o);
206     r->supplemental_item_description = 0;
207     r->cost_info_type = 0;
208     r->copyright_compliance = 0;
209     r->third_party_info_type = 0;
210     r->retry_flag = ill_get_bool (o, 0);
211     r->forward_flag = ill_get_bool (o, 0);
212     r->requester_note = 0;
213     r->forward_note = 0;
214     r->num_iLL_request_extensions = 0;
215     r->iLL_request_extensions = 0;
216     return r;
217 }