X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=ill%2Fill-get.c;h=f95375218d3fef1baa29f6d933bf0a494007f902;hp=9ebe29754c1bec35acff866558ed2071d3490b3e;hb=c71d717ada2a9ef730d527f161eb5ba9aa641a9f;hpb=c9f3e870fcf3f6f2dabb1046658c0a3804b14a55 diff --git a/ill/ill-get.c b/ill/ill-get.c index 9ebe297..f953752 100644 --- a/ill/ill-get.c +++ b/ill/ill-get.c @@ -1,9 +1,21 @@ /* - * Copyright (c) 1999-2000, Index Data. + * Copyright (c) 1999-2001, Index Data. * See the file LICENSE for details. * * $Log: ill-get.c,v $ - * Revision 1.5 2000-02-24 08:52:01 adam + * Revision 1.9 2001-03-25 21:55:12 adam + * Added odr_intdup. Ztest server returns TaskPackage for ItemUpdate. + * + * Revision 1.8 2001/02/21 13:46:53 adam + * C++ fixes. + * + * Revision 1.7 2001/02/20 11:25:32 adam + * Added ill_get_APDU and ill_get_Cancel. + * + * Revision 1.6 2000/08/10 08:41:26 adam + * Fixes for ILL. + * + * Revision 1.5 2000/02/24 08:52:01 adam * Bug fix. * * Revision 1.4 2000/02/04 11:01:15 adam @@ -30,7 +42,7 @@ bool_t *ill_get_bool (struct ill_get_ctl *gc, const char *name, ODR o = gc->odr; char element[128]; const char *v; - bool_t *r = odr_malloc (o, sizeof(*r)); + bool_t *r = (bool_t *) odr_malloc (o, sizeof(*r)); strcpy(element, name); if (sub) @@ -54,7 +66,6 @@ int *ill_get_int (struct ill_get_ctl *gc, const char *name, ODR o = gc->odr; char element[128]; const char *v; - int *r = odr_malloc (o, sizeof(*r)); strcpy(element, name); if (sub) @@ -65,8 +76,7 @@ int *ill_get_int (struct ill_get_ctl *gc, const char *name, v = (gc->f)(gc->clientData, element); if (v) val = atoi(v); - *r = val; - return r; + return odr_intdup(o, val); } int *ill_get_enumerated (struct ill_get_ctl *gc, const char *name, @@ -75,8 +85,8 @@ int *ill_get_enumerated (struct ill_get_ctl *gc, const char *name, return ill_get_int(gc, name, sub, val); } -ILL_String *ill_get_ILL_String (struct ill_get_ctl *gc, const char *name, - const char *sub) +ILL_String *ill_get_ILL_String_x (struct ill_get_ctl *gc, const char *name, + const char *sub, const char *vdefault) { ILL_String *r = (ILL_String *) odr_malloc (gc->odr, sizeof(*r)); char element[128]; @@ -90,12 +100,19 @@ ILL_String *ill_get_ILL_String (struct ill_get_ctl *gc, const char *name, } v = (gc->f)(gc->clientData, element); if (!v) + v = vdefault; + if (!v) return 0; r->which = ILL_String_GeneralString; r->u.GeneralString = odr_strdup (gc->odr, v); return r; } +ILL_String *ill_get_ILL_String(struct ill_get_ctl *gc, const char *name, + const char *sub) +{ + return ill_get_ILL_String_x (gc, name, sub, 0); +} ILL_ISO_Date *ill_get_ILL_ISO_Date (struct ill_get_ctl *gc, const char *name, const char *sub, const char *val) @@ -142,7 +159,8 @@ ILL_Person_Or_Institution_Symbol *ill_get_Person_Or_Insitution_Symbol ( { char element[128]; ODR o = gc->odr; - ILL_Person_Or_Institution_Symbol *p = odr_malloc (o, sizeof(*p)); + ILL_Person_Or_Institution_Symbol *p = + (ILL_Person_Or_Institution_Symbol *) odr_malloc (o, sizeof(*p)); strcpy(element, name); if (sub) @@ -166,7 +184,8 @@ static ILL_Name_Of_Person_Or_Institution *ill_get_Name_Of_Person_Or_Institution( { char element[128]; ODR o = gc->odr; - ILL_Name_Of_Person_Or_Institution *p = odr_malloc (o, sizeof(*p)); + ILL_Name_Of_Person_Or_Institution *p = + (ILL_Name_Of_Person_Or_Institution *) odr_malloc (o, sizeof(*p)); strcpy(element, name); if (sub) @@ -223,9 +242,9 @@ ILL_Transaction_Id *ill_get_Transaction_Id (struct ill_get_ctl *gc, r->initial_requester_id = ill_get_System_Id (gc, element, "initial-requester-id"); r->transaction_group_qualifier = - ill_get_ILL_String (gc, element, "transaction-group-qualifier"); + ill_get_ILL_String_x (gc, element, "transaction-group-qualifier", ""); r->transaction_qualifier = - ill_get_ILL_String (gc, element, "transaction-qualifier"); + ill_get_ILL_String_x (gc, element, "transaction-qualifier", ""); r->sub_transaction_qualifier = ill_get_ILL_String (gc, element, "sub-transaction-qualifier"); return r; @@ -349,7 +368,7 @@ ILL_Item_Id *ill_get_Item_Id ( ill_get_ILL_String(gc, element, "publication-date-of-component"); r->author_of_article = ill_get_ILL_String(gc, element, "author-of-article"); - r->title_of_article = ill_get_ILL_String(gc, element, "title-or-article"); + r->title_of_article = ill_get_ILL_String(gc, element, "title-of-article"); r->pagination = ill_get_ILL_String(gc, element, "pagination"); r->national_bibliography_no = 0; r->iSBN = ill_get_ILL_String(gc, element, "ISBN"); @@ -362,14 +381,6 @@ ILL_Item_Id *ill_get_Item_Id ( return r; } -ILL_ItemRequest *ill_get_ItemRequest ( - struct ill_get_ctl *gc, const char *name, const char *sub) -{ - ODR o = gc->odr; - ILL_ItemRequest *r = (ILL_ItemRequest *)odr_malloc(o, sizeof(*r)); - return 0; -} - ILL_Client_Id *ill_get_Client_Id ( struct ill_get_ctl *gc, const char *name, const char *sub) @@ -529,7 +540,7 @@ ILL_Request *ill_get_ILLRequest ( r->requester_optional_messages = ill_get_Requester_Optional_Messages_Type ( gc, element,"requester-optional-messages"); - r->search_type = 0; /* TODO */ + r->search_type = ill_get_Search_Type(gc, element, "search-type"); r->num_supply_medium_info_type = 0; r->supply_medium_info_type = 0; @@ -552,3 +563,128 @@ ILL_Request *ill_get_ILLRequest ( r->iLL_request_extensions = 0; return r; } + +ILL_ItemRequest *ill_get_ItemRequest ( + struct ill_get_ctl *gc, const char *name, const char *sub) +{ + ODR o = gc->odr; + ILL_ItemRequest *r = (ILL_ItemRequest *)odr_malloc(o, sizeof(*r)); + char element[128]; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + r->protocol_version_num = + ill_get_enumerated (gc, element, "protocol-version-num", + ILL_Request_version_2); + + r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id"); + r->service_date_time = + ill_get_Service_Date_Time (gc, element, "service-date-time"); + r->requester_id = ill_get_System_Id (gc, element, "requester-id"); + r->responder_id = ill_get_System_Id (gc, element, "responder-id"); + r->transaction_type = + ill_get_enumerated(gc, element, "transaction-type", 1); + + r->delivery_address = + ill_get_Delivery_Address (gc, element, "delivery-address"); + r->delivery_service = 0; /* TODO */ + /* ill_get_Delivery_Service (gc, element, "delivery-service"); */ + r->billing_address = + ill_get_Delivery_Address (gc, element, "billing-address"); + + r->num_iLL_service_type = 1; + r->iLL_service_type = (ILL_Service_Type **) + odr_malloc (o, sizeof(*r->iLL_service_type)); + *r->iLL_service_type = + ill_get_enumerated (gc, element, "ill-service-type", + ILL_Service_Type_copy_non_returnable); + + r->responder_specific_service = 0; + r->requester_optional_messages = + ill_get_Requester_Optional_Messages_Type ( + gc, element,"requester-optional-messages"); + r->search_type = ill_get_Search_Type(gc, element, "search-type"); + r->num_supply_medium_info_type = 0; + r->supply_medium_info_type = 0; + + r->place_on_hold = ill_get_enumerated ( + gc, element, "place-on-hold", + ILL_Place_On_Hold_Type_according_to_responder_policy); + r->client_id = ill_get_Client_Id (gc, element, "client-id"); + + r->item_id = ill_get_Item_Id (gc, element, "item-id"); + r->supplemental_item_description = 0; + r->cost_info_type = 0; + r->copyright_compliance = + ill_get_ILL_String(gc, element, "copyright-complicance"); + r->third_party_info_type = 0; + r->retry_flag = ill_get_bool (gc, element, "retry-flag", 0); + r->forward_flag = ill_get_bool (gc, element, "forward-flag", 0); + r->requester_note = ill_get_ILL_String(gc, element, "requester-note"); + r->forward_note = ill_get_ILL_String(gc, element, "forward-note"); + r->num_iLL_request_extensions = 0; + r->iLL_request_extensions = 0; + return r; +} + +ILL_Cancel *ill_get_Cancel ( + struct ill_get_ctl *gc, const char *name, const char *sub) +{ + ODR o = gc->odr; + ILL_Cancel *r = (ILL_Cancel *)odr_malloc(o, sizeof(*r)); + char element[128]; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + r->protocol_version_num = + ill_get_enumerated (gc, element, "protocol-version-num", + ILL_Request_version_2); + + r->transaction_id = ill_get_Transaction_Id (gc, element, "transaction-id"); + r->service_date_time = + ill_get_Service_Date_Time (gc, element, "service-date-time"); + r->requester_id = ill_get_System_Id (gc, element, "requester-id"); + r->responder_id = ill_get_System_Id (gc, element, "responder-id"); + r->requester_note = ill_get_ILL_String(gc, element, "requester-note"); + + r->num_cancel_extensions = 0; + r->cancel_extensions = 0; + return r; +} + +ILL_APDU *ill_get_APDU ( + struct ill_get_ctl *gc, const char *name, const char *sub) +{ + ODR o = gc->odr; + ILL_APDU *r = (ILL_APDU *)odr_malloc(o, sizeof(*r)); + char element[128]; + const char *v; + + strcpy (element, name); + strcat (element, ",which"); + + v = (gc->f)(gc->clientData, element); + if (!v) + v = "request"; + if (!strcmp (v, "request")) + { + r->which = ILL_APDU_ILL_Request; + r->u.illRequest = ill_get_ILLRequest(gc, name, sub); + } + else if (!strcmp (v, "cancel")) + { + r->which = ILL_APDU_Cancel; + r->u.Cancel = ill_get_Cancel(gc, name, sub); + } + else + return 0; + return r; +}