* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.202 2003-07-14 12:59:23 adam Exp $
+ * $Id: client.c,v 1.208 2003-09-04 18:51:49 adam Exp $
*/
#include <stdio.h>
printf("Version: %s\n", res->implementationVersion);
if (res->userInformationField)
{
+ Z_External *uif = res->userInformationField;
printf("UserInformationfield:\n");
- if (!z_External(print, (Z_External**)&res-> userInformationField,
- 0, 0))
+ if (!z_External(print, (Z_External**)&uif, 0, 0))
{
odr_perror(print, "Printing userinfo\n");
odr_reset(print);
}
- if (res->userInformationField->which == Z_External_octet)
+ if (uif->which == Z_External_octet)
{
printf("Guessing visiblestring:\n");
- printf("'%s'\n", res->userInformationField->u. octet_aligned->buf);
- }
+ printf("'%s'\n", uif->u. octet_aligned->buf);
+ } else if (uif->which == Z_External_single) {
+ /* Peek at any private Init-diagnostic APDUs */
+ Odr_any *sat = uif->u.single_ASN1_type;
+ printf("### NAUGHTY: External is '%s'\n", sat->buf);
+ }
odr_reset (print);
}
printf ("Options:");
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");
r = sscanf (arg, "%39s %39s %39s", user, group, pass);
if (r == 0)
{
- printf("Auth field set to null\n");
+ printf("Authentication set to null\n");
auth = 0;
}
if (r == 1)
{
auth = &au;
- au.which = Z_IdAuthentication_open;
- au.u.open = user;
+ if (!strcmp(user, "-")) {
+ au.which = Z_IdAuthentication_anonymous;
+ printf("Authentication set to Anonymous\n");
+ } else {
+ au.which = Z_IdAuthentication_open;
+ au.u.open = user;
+ printf("Authentication set to Open (%s)\n", user);
+ }
}
if (r == 2)
{
idPass.groupId = NULL;
idPass.userId = user;
idPass.password = group;
+ printf("Authentication set to User (%s), Pass (%s)\n", user, group);
}
if (r == 3)
{
idPass.groupId = group;
idPass.userId = user;
idPass.password = pass;
+ printf("Authentication set to User (%s), Group (%s), Pass (%s)\n",
+ user, group, pass);
}
return 1;
}
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;
}
{"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},