* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.205 2003-07-23 12:57:22 mike Exp $
+ * $Id: client.c,v 1.209 2003-10-17 14:13:59 adam Exp $
*/
#include <stdio.h>
static char *codeset = 0; /* character set for output */
static int hex_dump = 0;
+static char *dump_file_prefix = 0;
static ODR out, in, print; /* encoding and decoding streams */
#if HAVE_XML2
static ODR srw_sr_odr_out = 0;
printf("\n");
}
}
+ if (dump_file_prefix)
+ {
+ static int no = 0;
+ if (++no < 1000 && strlen(dump_file_prefix) < 500)
+ {
+ char fname[1024];
+ FILE *of;
+ sprintf (fname, "%s.%03d.raw", dump_file_prefix, no);
+ of = fopen(fname, "wb");
+
+ fwrite (buf, 1, len, of);
+
+ fclose(of);
+ }
+ }
}
void add_otherInfos(Z_APDU *a)
if (ber_file)
odr_dumpBER(ber_file, buf, len);
/* printf ("sending APDU of size %d\n", len); */
+ do_hex_dump(buf, len);
if (cs_put(conn, buf, len) < 0)
{
fprintf(stderr, "cs_put: %s", cs_errmsg(cs_errno(conn)));
close_session();
return 0;
}
- do_hex_dump(buf,len);
odr_reset(out); /* release the APDU structure */
return 1;
}
yaz_get_response_charneg(session_mem, p, &charset, &lang,
&selected);
+
+ if (outputCharset && negotiationCharset) {
+ odr_set_charset (out, charset, outputCharset);
+ odr_set_charset (in, outputCharset, charset);
+ }
+ else {
+ odr_set_charset (out, 0, 0);
+ odr_set_charset (in, 0, 0);
+ }
printf("Accepted character set : %s\n", charset);
printf("Accepted code language : %s\n", lang ? lang : "none");
/* we don't odr_reset(out), since we may need the buffer again */
+ do_hex_dump(buf_out, len_out);
+
r = cs_put(conn, buf_out, len_out);
odr_destroy(o);
return 0;
}
+static int cmd_update_common(const char *arg, int version);
+
static int cmd_update(const char *arg)
{
+ return cmd_update_common(arg, 1);
+}
+
+static int cmd_update0(const char *arg)
+{
+ return cmd_update_common(arg, 0);
+}
+
+static int cmd_update_common(const char *arg, int version)
+{
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;
char action[20], recid[20], fname[80];
int action_no;
update_oid.proto = PROTO_Z3950;
update_oid.oclass = CLASS_EXTSERV;
- update_oid.value = VAL_DBUPDATE;
+ if (version == 0)
+ update_oid.value = VAL_DBUPDATE0;
+ else
+ update_oid.value = VAL_DBUPDATE;
oid_ent_to_oid (&update_oid, oid);
req->packageType = odr_oiddup(out,oid);
req->packageName = esPackageName;
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 = action_no;
-
- 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]->which = Z_IUSuppliedRecords_elem_opaque;
- if (*recid)
- {
- notToKeep->elements[0]->u.opaque = (Odr_oct *)
- odr_malloc (out, sizeof(Odr_oct));
- notToKeep->elements[0]->u.opaque->buf = (unsigned char *) recid;
- notToKeep->elements[0]->u.opaque->size = strlen(recid);
- notToKeep->elements[0]->u.opaque->len = strlen(recid);
+ if (version == 0)
+ {
+ Z_IU0OriginPartToKeep *toKeep;
+ Z_IU0SuppliedRecords *notToKeep;
+
+ r->which = Z_External_update0;
+ r->u.update0 = (Z_IU0Update *) odr_malloc(out, sizeof(*r->u.update0));
+ r->u.update0->which = Z_IUUpdate_esRequest;
+ r->u.update0->u.esRequest = (Z_IU0UpdateEsRequest *)
+ odr_malloc(out, sizeof(*r->u.update0->u.esRequest));
+ toKeep = r->u.update0->u.esRequest->toKeep = (Z_IU0OriginPartToKeep *)
+ odr_malloc(out, sizeof(*r->u.update0->u.esRequest->toKeep));
+
+ toKeep->databaseName = databaseNames[0];
+ toKeep->schema = 0;
+ toKeep->elementSetName = 0;
+
+ toKeep->action = (int *) odr_malloc(out, sizeof(*toKeep->action));
+ *toKeep->action = action_no;
+
+ notToKeep = r->u.update0->u.esRequest->notToKeep = (Z_IU0SuppliedRecords *)
+ odr_malloc(out, sizeof(*r->u.update0->u.esRequest->notToKeep));
+ notToKeep->num = 1;
+ notToKeep->elements = (Z_IU0SuppliedRecords_elem **)
+ odr_malloc(out, sizeof(*notToKeep->elements));
+ notToKeep->elements[0] = (Z_IU0SuppliedRecords_elem *)
+ odr_malloc(out, sizeof(**notToKeep->elements));
+ notToKeep->elements[0]->which = Z_IUSuppliedRecords_elem_opaque;
+ if (*recid)
+ {
+ notToKeep->elements[0]->u.opaque = (Odr_oct *)
+ odr_malloc (out, sizeof(Odr_oct));
+ notToKeep->elements[0]->u.opaque->buf = (unsigned char *) recid;
+ notToKeep->elements[0]->u.opaque->size = strlen(recid);
+ notToKeep->elements[0]->u.opaque->len = strlen(recid);
+ }
+ else
+ notToKeep->elements[0]->u.opaque = 0;
+ notToKeep->elements[0]->supplementalId = 0;
+ notToKeep->elements[0]->correlationInfo = 0;
+ notToKeep->elements[0]->record = record_this;
}
else
- notToKeep->elements[0]->u.opaque = 0;
- notToKeep->elements[0]->supplementalId = 0;
- notToKeep->elements[0]->correlationInfo = 0;
- notToKeep->elements[0]->record = record_this;
+ {
+ Z_IUOriginPartToKeep *toKeep;
+ Z_IUSuppliedRecords *notToKeep;
+
+ 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 = action_no;
+
+ 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]->which = Z_IUSuppliedRecords_elem_opaque;
+ if (*recid)
+ {
+ notToKeep->elements[0]->u.opaque = (Odr_oct *)
+ odr_malloc (out, sizeof(Odr_oct));
+ notToKeep->elements[0]->u.opaque->buf = (unsigned char *) recid;
+ notToKeep->elements[0]->u.opaque->size = strlen(recid);
+ notToKeep->elements[0]->u.opaque->len = strlen(recid);
+ }
+ else
+ notToKeep->elements[0]->u.opaque = 0;
+ notToKeep->elements[0]->supplementalId = 0;
+ notToKeep->elements[0]->correlationInfo = 0;
+ notToKeep->elements[0]->record = record_this;
+ }
send_apdu(apdu);
else
printf ("Output charset conversion disabled\n");
}
- if (outputCharset && negotiationCharset)
- {
- odr_set_charset (out, negotiationCharset, outputCharset);
- odr_set_charset (in, outputCharset, negotiationCharset);
- }
- else
- {
- odr_set_charset (out, 0, 0);
- odr_set_charset (in, 0, 0);
- }
+
return 1;
}
buf_out = odr_getbuf(out, &len_out, 0);
+ do_hex_dump(buf_out, len_out);
+
cs_put(conn, buf_out, len_out);
odr_reset(out);
{"refid", cmd_refid, "<id>",NULL,0,NULL},
{"itemorder", cmd_itemorder, "ill|item <itemno>",NULL,0,NULL},
{"update", cmd_update, "<action> <recid> [<file>]",NULL,0,NULL},
+ {"update0", cmd_update0, "<action> <recid> [<file>]",NULL,0,NULL},
{"packagename", cmd_packagename, "<packagename>",NULL,0,NULL},
{"proxy", cmd_proxy, "[('tcp'|'ssl')]<host>[':'<port>]",NULL,0,NULL},
{"charset", cmd_charset, "<nego_charset> <output_charset>",NULL,0,NULL},
if (codeset)
outputCharset = xstrdup(codeset);
- while ((ret = options("k:c:q:a:b:m:v:p:u:t:Vx", argv, argc, &arg)) != -2)
+ while ((ret = options("k:c:q:a:b:m:v:p:u:t:Vxd:", argv, argc, &arg)) != -2)
{
switch (ret)
{
strcat (open_command, arg);
}
break;
+ case 'd':
+ dump_file_prefix = arg;
+ break;
case 'k':
kilobytes = atoi(arg);
break;
fprintf (stderr, "Usage: %s [-m <marclog>] [ -a <apdulog>] "
"[-b berdump] [-c cclfields] \n"
"[-q cqlfields] [-p <proxy-addr>] [-u <auth>] "
- "[-k size] [-V] [<server-addr>]\n",
+ "[-k size] [-d dump] [-V] [<server-addr>]\n",
prog);
exit (1);
}