+ else
+ {
+ oident oid;
+
+ item_request_buf = odr_getbuf (out, &item_request_size, 0);
+ oid.proto = PROTO_GENERAL;
+ oid.oclass = CLASS_GENERAL;
+ oid.value = VAL_ISO_ILL_1;
+
+ r = (Z_External *) odr_malloc (out, sizeof(*r));
+ r->direct_reference = odr_oiddup(out,oid_getoidbyent(&oid));
+ r->indirect_reference = 0;
+ r->descriptor = 0;
+ r->which = Z_External_single;
+
+ r->u.single_ASN1_type = (Odr_oct *)
+ odr_malloc (out, sizeof(*r->u.single_ASN1_type));
+ r->u.single_ASN1_type->buf = odr_malloc (out, item_request_size);
+ r->u.single_ASN1_type->len = item_request_size;
+ r->u.single_ASN1_type->size = item_request_size;
+ memcpy (r->u.single_ASN1_type->buf, item_request_buf,
+ item_request_size);
+ printf ("len = %d\n", item_request_size);
+ }
+ return r;
+}
+#else
+static Z_External *create_external_itemRequest()
+{
+ return 0;
+}
+#endif
+
+#ifdef ASN_COMPILED
+static Z_External *create_external_ILLRequest()
+{
+ struct ill_get_ctl ctl;
+ ILL_Request *req;
+ Z_External *r = 0;
+ int ill_request_size = 0;
+ char *ill_request_buf = 0;
+
+ ctl.odr = out;
+ ctl.clientData = 0;
+ ctl.f = get_ill_element;
+
+ req = ill_get_ILLRequest(&ctl, "ill", 0);
+
+ if (!ill_Request (out, &req, 0, 0))
+ {
+ if (apdu_file)
+ {
+ printf ("-------------------\n");
+ ill_Request(print, &req, 0, 0);
+ odr_reset(print);
+ printf ("-------------------\n");
+ }
+ ill_request_buf = odr_getbuf (out, &ill_request_size, 0);
+ if (ill_request_buf)
+ odr_setbuf (out, ill_request_buf, ill_request_size, 1);
+ printf ("Couldn't encode ILL-Request, size %d\n", ill_request_size);
+ return 0;
+ }
+ else
+ {
+ oident oid;
+ ill_request_buf = odr_getbuf (out, &ill_request_size, 0);
+
+ oid.proto = PROTO_GENERAL;
+ oid.oclass = CLASS_GENERAL;
+ oid.value = VAL_ISO_ILL_1;
+
+ r = (Z_External *) odr_malloc (out, sizeof(*r));
+ r->direct_reference = odr_oiddup(out,oid_getoidbyent(&oid));
+ r->indirect_reference = 0;
+ r->descriptor = 0;
+ r->which = Z_External_single;
+
+ r->u.single_ASN1_type = (Odr_oct *)
+ odr_malloc (out, sizeof(*r->u.single_ASN1_type));
+ r->u.single_ASN1_type->buf = odr_malloc (out, ill_request_size);
+ r->u.single_ASN1_type->len = ill_request_size;
+ r->u.single_ASN1_type->size = ill_request_size;
+ memcpy (r->u.single_ASN1_type->buf, ill_request_buf, ill_request_size);
+ printf ("len = %d\n", ill_request_size);
+ }
+ return r;
+}
+#else
+static Z_External *create_external_ILLRequest()
+{
+ return 0;
+}
+#endif
+
+
+static Z_External *create_ItemOrderExternal(const char *type, int itemno)
+{
+ Z_External *r = (Z_External *) odr_malloc(out, sizeof(Z_External));
+ oident ItemOrderRequest;
+
+ ItemOrderRequest.proto = PROTO_Z3950;
+ ItemOrderRequest.oclass = CLASS_EXTSERV;
+ ItemOrderRequest.value = VAL_ITEMORDER;
+
+ r->direct_reference = odr_oiddup(out,oid_getoidbyent(&ItemOrderRequest));
+ r->indirect_reference = 0;
+ r->descriptor = 0;
+
+ r->which = Z_External_itemOrder;
+
+ r->u.itemOrder = (Z_ItemOrder *) odr_malloc(out,sizeof(Z_ItemOrder));
+ memset(r->u.itemOrder, 0, sizeof(Z_ItemOrder));
+#ifdef ASN_COMPILED
+ r->u.itemOrder->which=Z_IOItemOrder_esRequest;
+#else
+ r->u.itemOrder->which=Z_ItemOrder_esRequest;
+#endif
+
+ r->u.itemOrder->u.esRequest = (Z_IORequest *)
+ odr_malloc(out,sizeof(Z_IORequest));
+ memset(r->u.itemOrder->u.esRequest, 0, sizeof(Z_IORequest));
+
+ r->u.itemOrder->u.esRequest->toKeep = (Z_IOOriginPartToKeep *)
+ odr_malloc(out,sizeof(Z_IOOriginPartToKeep));
+ memset(r->u.itemOrder->u.esRequest->toKeep, 0, sizeof(Z_IOOriginPartToKeep));
+ r->u.itemOrder->u.esRequest->notToKeep = (Z_IOOriginPartNotToKeep *)
+ odr_malloc(out,sizeof(Z_IOOriginPartNotToKeep));
+ memset(r->u.itemOrder->u.esRequest->notToKeep, 0, sizeof(Z_IOOriginPartNotToKeep));
+
+ r->u.itemOrder->u.esRequest->toKeep->supplDescription = NULL;
+ r->u.itemOrder->u.esRequest->toKeep->contact = NULL;
+ r->u.itemOrder->u.esRequest->toKeep->addlBilling = NULL;
+
+ r->u.itemOrder->u.esRequest->notToKeep->resultSetItem =
+ (Z_IOResultSetItem *) odr_malloc(out, sizeof(Z_IOResultSetItem));
+ memset(r->u.itemOrder->u.esRequest->notToKeep->resultSetItem, 0, sizeof(Z_IOResultSetItem));
+ r->u.itemOrder->u.esRequest->notToKeep->resultSetItem->resultSetId = "1";
+
+ r->u.itemOrder->u.esRequest->notToKeep->resultSetItem->item =
+ (int *) odr_malloc(out, sizeof(int));
+ *r->u.itemOrder->u.esRequest->notToKeep->resultSetItem->item = itemno;
+
+ switch (*type)
+ {
+ case '2':
+ printf ("using item-request\n");
+ r->u.itemOrder->u.esRequest->notToKeep->itemRequest =
+ create_external_itemRequest();
+ break;
+ case '1':
+ printf ("using ILL-request\n");
+ r->u.itemOrder->u.esRequest->notToKeep->itemRequest =
+ create_external_ILLRequest();
+ break;
+ default:
+ r->u.itemOrder->u.esRequest->notToKeep->itemRequest = 0;
+ }
+ return r;
+}
+
+static int send_itemorder(const char *type, int itemno)
+{
+ Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest );
+ Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
+ oident ItemOrderRequest;
+
+ ItemOrderRequest.proto = PROTO_Z3950;
+ ItemOrderRequest.oclass = CLASS_EXTSERV;
+ ItemOrderRequest.value = VAL_ITEMORDER;
+ req->packageType = odr_oiddup(out,oid_getoidbyent(&ItemOrderRequest));
+ req->packageName = "1.Extendedserveq";
+
+ req->taskSpecificParameters = create_ItemOrderExternal(type, itemno);
+
+ send_apdu(apdu);
+ return 0;
+}
+
+static int cmd_update(char *arg)
+{
+ Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest );
+ Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
+ Z_External *r;
+ int oid[OID_SIZE];
+ Z_IUOriginPartToKeep *toKeep;
+ Z_IUSuppliedRecords *notToKeep;
+ oident update_oid;
+ printf ("Update request\n");
+ fflush(stdout);
+
+ if (!record_last)
+ return 0;
+ update_oid.proto = PROTO_Z3950;
+ update_oid.oclass = CLASS_EXTSERV;
+ update_oid.value = VAL_DBUPDATE;
+ oid_ent_to_oid (&update_oid, oid);
+ req->packageType = odr_oiddup(out,oid);
+ req->packageName = "1.Extendedserveq";
+
+ r = req->taskSpecificParameters = (Z_External *)
+ odr_malloc (out, sizeof(*r));
+ r->direct_reference = odr_oiddup(out,oid);
+ r->indirect_reference = 0;
+ r->descriptor = 0;
+ r->which = Z_External_update;
+ r->u.update = (Z_IUUpdate *) odr_malloc(out, sizeof(*r->u.update));
+ r->u.update->which = Z_IUUpdate_esRequest;
+ r->u.update->u.esRequest = (Z_IUUpdateEsRequest *)
+ odr_malloc(out, sizeof(*r->u.update->u.esRequest));
+ toKeep = r->u.update->u.esRequest->toKeep = (Z_IUOriginPartToKeep *)
+ odr_malloc(out, sizeof(*r->u.update->u.esRequest->toKeep));
+ toKeep->databaseName = databaseNames[0];
+ toKeep->schema = 0;
+ toKeep->elementSetName = 0;
+ toKeep->actionQualifier = 0;
+ toKeep->action = (int *) odr_malloc(out, sizeof(*toKeep->action));
+ *toKeep->action = Z_IUOriginPartToKeep_recordInsert;
+
+ notToKeep = r->u.update->u.esRequest->notToKeep = (Z_IUSuppliedRecords *)
+ odr_malloc(out, sizeof(*r->u.update->u.esRequest->notToKeep));
+ notToKeep->num = 1;
+ notToKeep->elements = (Z_IUSuppliedRecords_elem **)
+ odr_malloc(out, sizeof(*notToKeep->elements));
+ notToKeep->elements[0] = (Z_IUSuppliedRecords_elem *)
+ odr_malloc(out, sizeof(**notToKeep->elements));
+ notToKeep->elements[0]->u.number = 0;
+ notToKeep->elements[0]->supplementalId = 0;
+ notToKeep->elements[0]->correlationInfo = 0;
+ notToKeep->elements[0]->record = record_last;
+
+ send_apdu(apdu);
+
+ return 2;
+}
+
+/* II : Added to do DALI Item Order Extended services request */
+static int cmd_itemorder(char *arg)
+{
+ char type[12];
+ int itemno;
+
+ if (sscanf (arg, "%10s %d", type, &itemno) != 2)