* Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.292 2005-06-25 15:46:01 adam Exp $
+ * $Id: client.c,v 1.296 2005-08-24 11:25:34 heikki Exp $
*/
#include <stdio.h>
static int scan_position = 1;
static int scan_size = 20;
static char cur_host[200];
+static int last_hit_count = 0;
typedef enum {
QueryType_Prefix,
if (oid->value == VAL_OCLCUI) {
Z_OCLC_UserInformation *oclc_ui;
ODR decode = odr_createmem(ODR_DECODE);
- odr_setbuf(decode, sat->buf, sat->len, 0);
+ odr_setbuf(decode, (char *) sat->buf, sat->len, 0);
if (!z_OCLC_UserInformation(decode, &oclc_ui, 0, 0))
printf ("Bad OCLC UserInformation:\n");
else
else
printf("Search was a bloomin' failure.\n");
printf("Number of hits: %d", *res->resultCount);
+ last_hit_count = *res->resultCount;
if (setnumber >= 0)
printf (", setno %d", setnumber);
printf ("\n");
static int only_z3950()
{
+ if (!conn)
+ {
+ printf ("Not connected yet\n");
+ return 1;
+ }
if (protocol == PROTO_HTTP)
{
printf ("Not supported by SRW\n");
Z_External *record_this = 0;
if (only_z3950())
- return 0;
+ return 1;
*action = 0;
*recid = 0;
sscanf (arg, "%19s %19s%n", action, recid, &noread);
static int cmd_xmles(const char *arg)
{
- int noread = 0;
- char oid_str[51];
- int oid_value_xmles = VAL_XMLES;
- Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest);
- Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
-
- Z_External *ext = (Z_External *) odr_malloc(out, sizeof(*ext));
- req->taskSpecificParameters = ext;
- ext->descriptor = 0;
- ext->which = Z_External_octet;
- ext->u.single_ASN1_type = (Odr_oct *) odr_malloc (out, sizeof(Odr_oct));
-
- sscanf(arg, "%50s%n", oid_str, &noread);
- if (noread == 0)
- {
- printf("Missing OID for xmles\n");
- return 0;
- }
- arg += noread;
- oid_value_xmles = oid_getvalbyname(oid_str);
- if (oid_value_xmles == VAL_NONE)
+ if (only_z3950())
+ return 1;
+ else
{
- printf("Bad OID: %s\n", oid_str);
- return 0;
+ int noread = 0;
+ char oid_str[51];
+ int oid_value_xmles = VAL_XMLES;
+ Z_APDU *apdu = zget_APDU(out, Z_APDU_extendedServicesRequest);
+ Z_ExtendedServicesRequest *req = apdu->u.extendedServicesRequest;
+
+ Z_External *ext = (Z_External *) odr_malloc(out, sizeof(*ext));
+
+ req->taskSpecificParameters = ext;
+ ext->indirect_reference = 0;
+ ext->descriptor = 0;
+ ext->which = Z_External_octet;
+ ext->u.single_ASN1_type = (Odr_oct *) odr_malloc (out, sizeof(Odr_oct));
+ sscanf(arg, "%50s%n", oid_str, &noread);
+ if (noread == 0)
+ {
+ printf("Missing OID for xmles\n");
+ return 0;
+ }
+ arg += noread;
+ oid_value_xmles = oid_getvalbyname(oid_str);
+ if (oid_value_xmles == VAL_NONE)
+ {
+ printf("Bad OID: %s\n", oid_str);
+ return 0;
+ }
+
+ if (parse_cmd_doc(&arg, out, (char **) &ext->u.single_ASN1_type->buf,
+ &ext->u.single_ASN1_type->len, 0) == 0)
+ return 0;
+ req->packageType = yaz_oidval_to_z3950oid(out, CLASS_EXTSERV,
+ oid_value_xmles);
+
+ ext->direct_reference = yaz_oidval_to_z3950oid(out, CLASS_EXTSERV,
+ oid_value_xmles);
+ send_apdu(apdu);
+
+ return 2;
}
-
- if (parse_cmd_doc(&arg, out, (char **) &ext->u.single_ASN1_type->buf,
- &ext->u.single_ASN1_type->len, 0) == 0)
- return 0;
- req->packageType = yaz_oidval_to_z3950oid(out, CLASS_EXTSERV,
- oid_value_xmles);
-
- ext->direct_reference = yaz_oidval_to_z3950oid(out, CLASS_EXTSERV,
- oid_value_xmles);
- send_apdu(apdu);
-
- return 2;
}
static int cmd_itemorder(const char *arg)
int itemno;
if (only_z3950())
- return 0;
+ return 1;
if (sscanf (arg, "%10s %d", type, &itemno) != 2)
return 0;
strncpy (cur_host, arg, sizeof(cur_host)-1);
cur_host[sizeof(cur_host)-1] = 0;
}
- if (!conn || protocol != PROTO_Z3950)
- return 0;
+ if (only_z3950())
+ return 1;
send_initRequest(cur_host);
return 2;
}
static int cmd_delete(const char *arg)
{
- if (!conn)
- {
- printf("Not connected yet\n");
- return 0;
- }
if (only_z3950())
return 0;
if (!send_deleteResultSetRequest(arg))
static int cmd_lslb(const char *arg)
{
- if (only_z3950())
- return 0;
if (!(largeSetLowerBound = atoi(arg)))
return 0;
return 1;
static int cmd_mspn(const char *arg)
{
- if (only_z3950())
- return 0;
if (!(mediumSetPresentNumber = atoi(arg)))
return 0;
return 1;
*p = '\0';
}
if (*arg)
- *start = atoi(arg);
+ {
+ if (!strcmp(arg, "all"))
+ {
+ *number = last_hit_count;
+ *start = 1;
+ }
+ else
+ *start = atoi(arg);
+ }
if (p && (p=strchr(p+1, '+')))
strcpy (setstring, p+1);
else if (setnumber >= 0)
odr_reset(out);
odr_reset(in);
odr_reset(print);
+ last_hit_count = 0;
}
void process_close(Z_Close *req)
apdu->u.triggerResourceControlRequest;
bool_t rfalse = 0;
- if (!conn)
- {
- printf("Session not initialized yet\n");
- return 0;
- }
if (only_z3950())
return 0;
if (session_initResponse &&
int cmd_sort_generic(const char *arg, int newset)
{
- if (!conn)
- {
- printf("Session not initialized yet\n");
- return 0;
- }
if (only_z3950())
return 0;
if (session_initResponse &&
{
Z_APDU *apdu;
Z_Close *req;
- if (!conn)
- return 0;
if (only_z3950())
return 0;
-
apdu = zget_APDU(out, Z_APDU_close);
req = apdu->u.close;
*req->closeReason = Z_Close_finished;
} cmd_array[] = {
{"open", cmd_open, "('tcp'|'ssl')':<host>[':'<port>][/<db>]",NULL,0,NULL},
{"quit", cmd_quit, "",NULL,0,NULL},
+ {"exit", cmd_quit, "",NULL,0,NULL},
{"find", cmd_find, "<query>",NULL,0,NULL},
{"delete", cmd_delete, "<setname>",NULL,0,NULL},
{"base", cmd_base, "<base-name>",NULL,0,NULL},
void process_cmd_line(char* line)
{
- int i,res;
+ int i, res;
char word[32], arg[10240];
#if HAVE_GETTIMEOFDAY