/*
- * Copyright (c) 1995-2003, Index Data
+ * Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.217 2003-12-22 19:46:22 adam Exp $
+ * $Id: client.c,v 1.223 2004-01-07 21:02:42 adam Exp $
*/
#include <stdio.h>
static int setno = 1; /* current set offset */
static enum oid_proto protocol = PROTO_Z3950; /* current app protocol */
static enum oid_value recordsyntax = VAL_USMARC;
-static char *schema = 0;
+static char *record_schema = 0;
static int sent_close = 0;
static NMEM session_mem = NULL; /* memory handle for init-response */
static Z_InitResponse *session = 0; /* session parameters */
char *buf_out;
int len_out;
int r;
- if (apdu_file && !z_GDU(print, &gdu, 0, 0))
- printf ("Failed to print outgoing APDU\n");
+ if (apdu_file)
+ {
+ if (!z_GDU(print, &gdu, 0, 0))
+ printf ("Failed to print outgoing APDU\n");
+ odr_reset(print);
+ }
buf_out = odr_getbuf(out, &len_out, 0);
/* we don't odr_reset(out), since we may need the buffer again */
sr = yaz_srw_get(out, Z_SRW_searchRetrieve_request);
sr->u.request->query_type = Z_SRW_query_type_cql;
sr->u.request->query.cql = odr_strdup(out, arg);
- if (schema)
- sr->u.request->recordSchema = schema;
+ if (record_schema)
+ sr->u.request->recordSchema = record_schema;
return send_srw(sr);
}
#endif
send_srw(sr);
return 2;
}
-#else
- return 0;
#endif
+ return 0;
}
static int cmd_find(const char *arg)
req->preferredRecordSyntax =
odr_oiddup (out, oid_ent_to_oid(&prefsyn, oid));
- if (schema)
+ if (record_schema)
{
oident prefschema;
prefschema.proto = protocol;
prefschema.oclass = CLASS_SCHEMA;
- prefschema.value = oid_getvalbyname(schema);
+ prefschema.value = oid_getvalbyname(record_schema);
req->recordComposition = &compo;
compo.which = Z_RecordComp_complex;
parse_show_args(arg, setstring, &setno, &nos);
sr->u.request->startRecord = odr_intdup(out, setno);
sr->u.request->maximumRecords = odr_intdup(out, nos);
- if (schema)
- sr->u.request->recordSchema = schema;
+ if (record_schema)
+ sr->u.request->recordSchema = record_schema;
return send_srw(sr);
}
#endif
int cmd_schema(const char *arg)
{
- xfree(schema);
- schema = 0;
+ xfree(record_schema);
+ record_schema = 0;
if (arg && *arg)
- schema = xstrdup(arg);
+ record_schema = xstrdup(arg);
return 1;
}
printf (" schema=%s", rec->recordSchema);
printf ("\n");
if (rec->recordData_buf && rec->recordData_len)
- {
fwrite(rec->recordData_buf, 1, rec->recordData_len, stdout);
- printf ("\n");
- }
+ else
+ printf ("No data!");
+ printf("\n");
}
static void handle_srw_explain_response(Z_SRW_explainResponse *res)
odr_dumpBER(f, netbuffer, res);
fprintf(f, "---------\n");
if (apdu_file)
+ {
z_GDU(print, &gdu, 0, 0);
+ odr_reset(print);
+ }
if (conn && cs_more(conn))
continue;
break;
/* print present related options */
printf("Format : %s\n",yaz_z3950_oid_value_to_str(recordsyntax,CLASS_RECSYN));
- printf("Schema : %s\n",schema);
+ printf("Schema : %s\n",record_schema ? record_schema : "not set");
printf("Elements : %s\n",elementSetNames?elementSetNames->u.generic:"");
/* loging options */