* Copyright (c) 2000-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.20 2004-01-22 11:20:54 adam Exp $
+ * $Id: zoom-c.c,v 1.24 2004-02-14 15:58:42 adam Exp $
*
* ZOOM layer for C, connections, result sets, queries.
*/
const char *dset,
const char *addinfo, const char *addinfo2)
{
+ char *cp;
xfree (c->addinfo);
c->addinfo = 0;
c->error = error;
- c->diagset = dset;
+ if (!c->diagset || strcmp(dset, c->diagset))
+ {
+ xfree(c->diagset);
+ c->diagset = xstrdup(dset);
+ /* remove integer part from SRW diagset .. */
+ if ((cp = strrchr(c->diagset, '/')))
+ *cp = '\0';
+ }
if (addinfo && addinfo2)
{
c->addinfo = xmalloc(strlen(addinfo) + strlen(addinfo2) + 2);
c->reconnect_ok = 0;
c->state = STATE_IDLE;
c->addinfo = 0;
+ c->diagset = 0;
set_ZOOM_error(c, ZOOM_ERROR_NONE, 0);
c->buf_in = 0;
c->len_in = 0;
s->z_query->which = Z_Query_type_1;
s->z_query->u.type_1 = p_query_rpn(s->odr, PROTO_Z3950, str);
if (!s->z_query->u.type_1)
+ {
+ s->z_query = 0;
return -1;
+ }
return 0;
}
xfree (c->buf_in);
xfree (c->addinfo);
+ xfree (c->diagset);
odr_destroy (c->odr_in);
odr_destroy (c->odr_out);
ZOOM_options_destroy (c->options);
ZOOM_options_get(c->options, "implementationName"),
odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName));
- version = odr_strdup(c->odr_out, "$Revision: 1.20 $");
+ version = odr_strdup(c->odr_out, "$Revision: 1.24 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
ireq->implementationVersion = odr_prepend(c->odr_out,
/* prepare query for the search request */
search_req->query = r->query->z_query;
+ if (!search_req->query)
+ {
+ set_ZOOM_error(c, ZOOM_ERROR_INVALID_QUERY, 0);
+ return zoom_complete;
+ }
search_req->databaseNames =
set_DatabaseNames (c, r->options, &search_req->num_databaseNames);
}
if (res->num_diagnostics > 0)
{
- set_dset_error(c, *res->diagnostics[0].code, "SRW",
- res->diagnostics[0].details, 0);
+ const char *uri = res->diagnostics[0].uri;
+ if (uri)
+ {
+ int code = 0;
+ const char *cp;
+ if ((cp = strrchr(uri, '/')))
+ code = atoi(cp+1);
+ set_dset_error(c, code, uri,
+ res->diagnostics[0].details, 0);
+ }
}
nmem = odr_extract_mem(c->odr_in);
nmem_transfer(resultset->odr->mem, nmem);
return "Unsupported protocol";
case ZOOM_ERROR_UNSUPPORTED_QUERY:
return "Unsupported query type";
+ case ZOOM_ERROR_INVALID_QUERY:
+ return "Invalid query";
default:
return diagbib1_str (error);
}
*cp = z_HTTP_errmsg(c->error);
else if (!strcmp(c->diagset, "Bib-1"))
*cp = ZOOM_diag_str(error);
- else if (!strcmp(c->diagset, "SRW"))
+ else if (!strcmp(c->diagset, "info:srw/diagnostic/1"))
*cp = yaz_diag_srw_str(c->error);
else
*cp = "Unknown error and diagnostic set";