* Copyright (c) 1995-2003, Index Data
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.190 2003-04-29 21:53:54 adam Exp $
+ * $Id: client.c,v 1.192 2003-05-12 22:35:06 adam Exp $
*/
#include <stdio.h>
return 0;
}
#endif
+ protocol = conn->protocol;
if (conn->protocol == PROTO_HTTP)
set_base("");
else
printf("OK.\n");
if (basep && *basep)
set_base (basep);
- if (conn->protocol == PROTO_Z3950)
+ if (protocol == PROTO_Z3950)
{
send_initRequest(type_and_host);
return 2;
}
odr_reset(srw_sr_odr_out);
+ setno = 1;
+
/* save this for later .. when fetching individual records */
srw_sr = sr = yaz_srw_get(srw_sr_odr_out, Z_SRW_searchRetrieve_request);
sr->u.request->query_type = Z_SRW_query_type_cql;
static int only_z3950()
{
- if (conn && conn->protocol == PROTO_HTTP)
+ if (protocol == PROTO_HTTP)
{
printf ("Not supported by SRW\n");
return 1;
printf("Find what?\n");
return 0;
}
- if (!conn)
- {
- try_reconnect();
-
- if (!conn) {
- printf("Not connected yet\n");
- return 0;
- }
- }
- if (conn->protocol == PROTO_HTTP)
+ if (protocol == PROTO_HTTP)
{
#if HAVE_XML2
+ if (!conn)
+ cmd_open(0);
if (!send_SRW_searchRequest(arg))
return 0;
#else
}
else
{
+ if (!conn)
+ {
+ try_reconnect();
+
+ if (!conn) {
+ printf("Not connected yet\n");
+ return 0;
+ }
+ }
if (!send_searchRequest(arg))
return 0;
}
static void close_session (void)
{
- cs_close (conn);
+ if (conn)
+ cs_close (conn);
conn = 0;
if (session_mem)
{
nmem_destroy (session_mem);
session_mem = NULL;
}
- if (srw_sr)
- {
- odr_destroy(srw_sr_odr_out);
- srw_sr_odr_out = 0;
- srw_sr = 0;
- }
- assert (srw_sr_odr_out == 0);
sent_close = 0;
odr_reset(out);
odr_reset(in);
static int cmd_show(const char *arg)
{
- if (!conn)
- {
- printf("Not connected yet\n");
- return 0;
- }
- if (conn->protocol == PROTO_HTTP)
+ if (protocol == PROTO_HTTP)
{
#if HAVE_XML2
+ if (!conn)
+ cmd_open(0);
if (!send_SRW_presentRequest(arg))
return 0;
#else
}
else
{
+ if (!conn)
+ {
+ printf("Not connected yet\n");
+ return 0;
+ }
if (!send_presentRequest(arg))
return 0;
}
for (i = 0; i<res->num_diagnostics; i++)
{
- printf ("SRW diagnostic %d %s\nDetails: %s\n",
+ printf ("SRW diagnostic %d %s\n",
*res->diagnostics[i].code,
- yaz_diag_srw_str(*res->diagnostics[i].code),
- res->diagnostics[i].details);
+ yaz_diag_srw_str(*res->diagnostics[i].code));
+
+ if (res->diagnostics[i].details)
+ printf ("Details: %s\n", res->diagnostics[i].details);
}
if (res->numberOfRecords)
printf ("Number of hits: %d\n", *res->numberOfRecords);
setno = *rec->recordPosition + 1;
}
if (rec->recordSchema)
- printf (" scheam=%d", *rec->recordSchema);
+ printf (" schema=%s", rec->recordSchema);
printf ("\n");
if (rec->recordData_buf && rec->recordData_len)
{
while(conn)
{
res = cs_get(conn, &netbuffer, &netbufferlen);
- if (reconnect_ok && res <= 0 && conn->protocol == PROTO_HTTP)
+ if (reconnect_ok && res <= 0 && protocol == PROTO_HTTP)
{
cs_close(conn);
conn = 0;