X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=ill%2Fill-get.c;h=f95375218d3fef1baa29f6d933bf0a494007f902;hp=fd86291a17c966bf836aea8c1abf62d32461067a;hb=c71d717ada2a9ef730d527f161eb5ba9aa641a9f;hpb=c126b2a625462f95475f00efdfdf9ce41a0e9c79 diff --git a/ill/ill-get.c b/ill/ill-get.c index fd86291..f953752 100644 --- a/ill/ill-get.c +++ b/ill/ill-get.c @@ -1,9 +1,27 @@ /* - * 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.3 2000-01-31 13:15:21 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 + * Added more elements. + * + * Revision 1.3 2000/01/31 13:15:21 adam * Removed uses of assert(3). Cleanup of ODR. CCL parser update so * that some characters are not surrounded by spaces in resulting term. * ILL-code updates. @@ -24,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) @@ -48,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) @@ -59,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, @@ -69,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]; @@ -84,18 +100,67 @@ 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) +{ + char element[128]; + const char *v; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + v = (gc->f)(gc->clientData, element); + if (!v) + v = val; + if (!v) + return 0; + return odr_strdup (gc->odr, v); +} + +ILL_ISO_Time *ill_get_ILL_ISO_Time (struct ill_get_ctl *gc, const char *name, + const char *sub, const char *val) +{ + char element[128]; + const char *v; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + v = (gc->f)(gc->clientData, element); + if (!v) + v = val; + if (!v) + return 0; + return odr_strdup (gc->odr, v); +} + ILL_Person_Or_Institution_Symbol *ill_get_Person_Or_Insitution_Symbol ( struct ill_get_ctl *gc, const char *name, const char *sub) { 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) @@ -119,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) @@ -153,12 +219,10 @@ ILL_System_Id *ill_get_System_Id(struct ill_get_ctl *gc, strcat (element, sub); } p = (ILL_System_Id *) odr_malloc (o, sizeof(*p)); - p->person_or_institution_symbol = - ill_get_Person_Or_Insitution_Symbol (gc, element, - "person-or-institution-symbol"); - p->name_of_person_or_institution = - ill_get_Name_Of_Person_Or_Institution (gc, element, - "name-of-person-or-institution"); + p->person_or_institution_symbol = ill_get_Person_Or_Insitution_Symbol ( + gc, element, "person-or-institution-symbol"); + p->name_of_person_or_institution = ill_get_Name_Of_Person_Or_Institution ( + gc, element, "name-of-person-or-institution"); return p; } @@ -178,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; @@ -201,8 +265,29 @@ ILL_Service_Date_this *ill_get_Service_Date_this ( strcat (element, ","); strcat (element, sub); } - r->date = odr_strdup (o, "14012000"); - r->time = 0; + r->date = ill_get_ILL_ISO_Date (gc, element, "date", "20000101"); + r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0); + return r; +} + +ILL_Service_Date_original *ill_get_Service_Date_original ( + struct ill_get_ctl *gc, const char *name, const char *sub) +{ + ODR o = gc->odr; + ILL_Service_Date_original *r = + (ILL_Service_Date_original *) odr_malloc (o, sizeof(*r)); + char element[128]; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + r->date = ill_get_ILL_ISO_Date (gc, element, "date", 0); + r->time = ill_get_ILL_ISO_Time (gc, element, "time", 0); + if (!r->date && !r->time) + return 0; return r; } @@ -220,9 +305,10 @@ ILL_Service_Date_Time *ill_get_Service_Date_Time ( strcat (element, ","); strcat (element, sub); } - r->date_time_of_this_service = ill_get_Service_Date_this (gc, element, - "this"); - r->date_time_of_original_service = 0; + r->date_time_of_this_service = ill_get_Service_Date_this ( + gc, element, "this"); + r->date_time_of_original_service = ill_get_Service_Date_original ( + gc, element, "original"); return r; } @@ -282,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"); @@ -295,12 +381,120 @@ ILL_Item_Id *ill_get_Item_Id ( return r; } -ILL_ItemRequest *ill_get_ItemRequest ( + +ILL_Client_Id *ill_get_Client_Id ( struct ill_get_ctl *gc, const char *name, const char *sub) { + char element[128]; ODR o = gc->odr; - ILL_ItemRequest *r = (ILL_ItemRequest *)odr_malloc(o, sizeof(*r)); - return 0; + ILL_Client_Id *r = (ILL_Client_Id *) odr_malloc(o, sizeof(*r)); + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + r->client_name = ill_get_ILL_String (gc, element, "client-name"); + r->client_status = ill_get_ILL_String (gc, element, "client-status"); + r->client_identifier = ill_get_ILL_String (gc, element, + "client-identifier"); + return r; +} + +ILL_Postal_Address *ill_get_Postal_Address ( + struct ill_get_ctl *gc, const char *name, const char *sub) +{ + ODR o = gc->odr; + ILL_Postal_Address *r = + (ILL_Postal_Address *) odr_malloc(o, sizeof(*r)); + char element[128]; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + r->name_of_person_or_institution = + ill_get_Name_Of_Person_Or_Institution ( + gc, element, "name-of-person-or-institution"); + r->extended_postal_delivery_address = + ill_get_ILL_String ( + gc, element, "extended-postal-delivery-address"); + r->street_and_number = + ill_get_ILL_String (gc, element, "street-and-number"); + r->post_office_box = + ill_get_ILL_String (gc, element, "post-office-box"); + r->city = ill_get_ILL_String (gc, element, "city"); + r->region = ill_get_ILL_String (gc, element, "region"); + r->country = ill_get_ILL_String (gc, element, "country"); + r->postal_code = ill_get_ILL_String (gc, element, "postal-code"); + return r; +} + +ILL_System_Address *ill_get_System_Address ( + struct ill_get_ctl *gc, const char *name, const char *sub) +{ + ODR o = gc->odr; + ILL_System_Address *r = + (ILL_System_Address *) odr_malloc(o, sizeof(*r)); + char element[128]; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + r->telecom_service_identifier = + ill_get_ILL_String (gc, element, "telecom-service-identifier"); + r->telecom_service_address = + ill_get_ILL_String (gc, element, "telecom-service-addreess"); + return r; +} + +ILL_Delivery_Address *ill_get_Delivery_Address ( + struct ill_get_ctl *gc, const char *name, const char *sub) +{ + ODR o = gc->odr; + ILL_Delivery_Address *r = + (ILL_Delivery_Address *) odr_malloc(o, sizeof(*r)); + char element[128]; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + r->postal_address = + ill_get_Postal_Address (gc, element, "postal-address"); + r->electronic_address = + ill_get_System_Address (gc, element, "electronic-address"); + return r; +} + +ILL_Search_Type *ill_get_Search_Type ( + struct ill_get_ctl *gc, const char *name, const char *sub) +{ + ODR o = gc->odr; + ILL_Search_Type *r = (ILL_Search_Type *) odr_malloc(o, sizeof(*r)); + char element[128]; + + strcpy(element, name); + if (sub) + { + strcat (element, ","); + strcat (element, sub); + } + r->level_of_service = ill_get_ILL_String (gc, element, "level-of-service"); + r->need_before_date = ill_get_ILL_ISO_Date (gc, element, + "need-before-date", 0); + r->expiry_date = ill_get_ILL_ISO_Date (gc, element, "expiry-date", 0); + r->expiry_flag = ill_get_enumerated (gc, element, "expiry-flag", 3); + + return r; } ILL_Request *ill_get_ILLRequest ( @@ -327,9 +521,13 @@ ILL_Request *ill_get_ILLRequest ( 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 = 0; /* TODO */ - r->delivery_service = 0; /* TODO */ - r->billing_address = 0; /* TODO */ + + 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 **) @@ -342,14 +540,15 @@ 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; - r->place_on_hold = - ill_get_enumerated (gc, element, "place-on-hold", - ILL_Place_On_Hold_Type_according_to_responder_policy); - r->client_id = 0; /* TODO */ + 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; @@ -364,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; +}