* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.355 2007-12-21 19:01:33 adam Exp $
+ * $Id: client.c,v 1.356 2007-12-27 13:27:40 adam Exp $
*/
/** \file client.c
* \brief yaz-client program
return 0;
}
#if YAZ_HAVE_XML2
- if (conn->protocol == PROTO_HTTP)
- queryType = QueryType_CQL;
#else
if (conn->protocol == PROTO_HTTP)
{
int cmd_open(const char *arg)
{
+ int r;
if (arg)
{
strncpy (cur_host, arg, sizeof(cur_host)-1);
cur_host[sizeof(cur_host)-1] = 0;
}
- return session_connect(cur_host);
+ r = session_connect(cur_host);
+ if (conn && conn->protocol == PROTO_HTTP)
+ queryType = QueryType_CQL;
+ return r;
}
void try_reconnect(void)
if (ext->which == Z_External_itemOrder)
{
Z_IOTaskPackage *otp = ext->u.itemOrder->u.taskPackage;
- if (otp && otp->targetPart && otp->targetPart->itemRequest)
+
+ if (otp && otp->targetPart )
{
- Z_External *ext = otp->targetPart->itemRequest;
- if (ext->which == Z_External_octet)
+ if (otp->targetPart->itemRequest)
{
- Odr_oct *doc = ext->u.octet_aligned;
- printf("Got itemRequest doc %.*s\n",
- doc->len, doc->buf);
+ Z_External *ext = otp->targetPart->itemRequest;
+ if (ext->which == Z_External_octet)
+ {
+ Odr_oct *doc = ext->u.octet_aligned;
+ printf("Got itemRequest doc %.*s\n",
+ doc->len, doc->buf);
+ }
}
- }
+ else if (otp->targetPart->statusOrErrorReport)
+ {
+ Z_External *ext = otp->targetPart->statusOrErrorReport;
+ if (ext->which == Z_External_octet)
+ {
+ Odr_oct *doc = ext->u.octet_aligned;
+ printf("Got Status or Error Report doc %.*s\n",
+ doc->len, doc->buf);
+ }
+ }
+ }
}
}
if (res->taskPackage && res->taskPackage->which == Z_External_octet)
}
-static Z_External *create_ItemOrderExternal(const char *type, int itemno)
+static Z_External *create_ItemOrderExternal(const char *type, int itemno,
+ const char *xml_buf,
+ int xml_len)
{
Z_External *r = (Z_External *) odr_malloc(out, sizeof(Z_External));
r->direct_reference = odr_oiddup(out, yaz_oid_extserv_item_order);
}
else if (!strcmp(type, "xml") || !strcmp(type, "3"))
{
- const char *xml_buf =
- "<itemorder>\n"
- " <type>request</type>\n"
- " <libraryNo>000200</libraryNo>\n"
- " <borrowerTicketNo> 1212 </borrowerTicketNo>\n"
- "</itemorder>";
- r->u.itemOrder->u.esRequest->notToKeep->itemRequest =
- z_ext_record_oid(out, yaz_oid_recsyn_xml, xml_buf, strlen(xml_buf));
+ printf("using XML ILL-request\n");
+
+ if (!xml_buf)
+ {
+ printf("no docoument added\n");
+ r->u.itemOrder->u.esRequest->notToKeep->itemRequest = 0;
+ }
+ else
+ {
+ r->u.itemOrder->u.esRequest->notToKeep->itemRequest =
+ z_ext_record_oid(out, yaz_oid_recsyn_xml, xml_buf, xml_len);
+ }
}
else
r->u.itemOrder->u.esRequest->notToKeep->itemRequest = 0;
return r;
}
-static int send_itemorder(const char *type, int itemno)
+static int send_itemorder(const char *type, int itemno,
+ const char *xml_buf, int xml_len)
{
Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest);
Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
req->packageType = odr_oiddup(out, yaz_oid_extserv_item_order);
req->packageName = esPackageName;
- req->taskSpecificParameters = create_ItemOrderExternal(type, itemno);
-
+ req->taskSpecificParameters = create_ItemOrderExternal(type, itemno,
+ xml_buf, xml_len);
send_apdu(apdu);
return 0;
}
char *rec_buf, int rec_len)
{
if (!conn)
- cmd_open(0);
+ session_connect(cur_host);
if (!conn)
return 0;
else
{
char type[12];
int itemno;
+ char *xml_buf = 0;
+ int xml_len = 0;
+ int no_read = 0;
if (only_z3950())
return 1;
- if (sscanf (arg, "%10s %d", type, &itemno) != 2)
+ if (sscanf(arg, "%10s %d%n", type, &itemno, &no_read) < 2)
return 0;
+ arg += no_read;
+ parse_cmd_doc(&arg, out, &xml_buf, &xml_len);
- printf("Item order request\n");
fflush(stdout);
- send_itemorder(type, itemno);
+ send_itemorder(type, itemno, xml_buf, xml_len);
return 2;
}
return 0;
#if YAZ_HAVE_XML2
if (!conn)
- cmd_open(0);
+ session_connect(cur_host);
if (conn)
{
Z_SRW_PDU *sr = 0;
{
#if YAZ_HAVE_XML2
if (!conn)
- cmd_open(0);
+ session_connect(cur_host);
if (!conn)
return 0;
if (!send_SRW_searchRequest(arg))
{
#if YAZ_HAVE_XML2
if (!conn)
- cmd_open(0);
+ session_connect(cur_host);
if (!conn)
return 0;
if (!send_SRW_presentRequest(arg))
{
#if YAZ_HAVE_XML2
if (!conn)
- cmd_open(0);
+ session_connect(cur_host);
if (!conn)
return 0;
if (*arg)
{
cs_close(conn);
conn = 0;
- cmd_open(0);
+ session_connect(cur_host);
reconnect_ok = 0;
if (conn)
{