From: Adam Dickmeiss Date: Tue, 27 Jan 2004 21:22:43 +0000 (+0000) Subject: Use prefix for SRW diagset in ZOOM X-Git-Tag: YAZ.2.0.10~3 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=4b7f94b22a4a670274c028db7f0e438f2d7d74a0;p=yaz-moved-to-github.git Use prefix for SRW diagset in ZOOM --- diff --git a/client/client.c b/client/client.c index f485347..90d3e94 100644 --- a/client/client.c +++ b/client/client.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2004, Index Data * See the file LICENSE for details. * - * $Id: client.c,v 1.227 2004-01-27 12:15:11 adam Exp $ + * $Id: client.c,v 1.228 2004-01-27 21:22:43 adam Exp $ */ #include @@ -3306,7 +3306,6 @@ static void handle_srw_response(Z_SRW_searchRetrieveResponse *res) { printf ("SRW diagnostic %s\n", res->diagnostics[i].code); - if (res->diagnostics[i].message) printf ("Message: %s\n", res->diagnostics[i].message); if (res->diagnostics[i].details) diff --git a/src/srw.c b/src/srw.c index ca8ff01..9fdadce 100644 --- a/src/srw.c +++ b/src/srw.c @@ -2,7 +2,7 @@ * Copyright (c) 2002-2004, Index Data. * See the file LICENSE for details. * - * $Id: srw.c,v 1.19 2004-01-27 12:15:12 adam Exp $ + * $Id: srw.c,v 1.20 2004-01-27 21:22:44 adam Exp $ */ #include @@ -321,7 +321,7 @@ static int yaz_srw_diagnostics(ODR o, xmlNodePtr pptr, Z_SRW_diagnostic **recs, xmlNewNs(pptr, "http://www.loc.gov/zing/srw/diagnostics/", "diag"); for (i = 0; i < *num; i++) { - const char *std_diag = "info:srw/diagnostic/1/1/"; + const char *std_diag = "info:srw/diagnostic/1/"; xmlNodePtr rptr = xmlNewChild(pptr, ns_diag, "diagnostic", 0); add_xsd_string(rptr, "code", (*recs)[i].code); if ((*recs)[i].message) diff --git a/src/srwutil.c b/src/srwutil.c index cd89a33..a7bc839 100644 --- a/src/srwutil.c +++ b/src/srwutil.c @@ -2,7 +2,7 @@ * Copyright (c) 2002-2004, Index Data. * See the file LICENSE for details. * - * $Id: srwutil.c,v 1.10 2004-01-27 12:15:12 adam Exp $ + * $Id: srwutil.c,v 1.11 2004-01-27 21:22:44 adam Exp $ */ #include @@ -135,7 +135,7 @@ void yaz_mk_std_diagnostic(ODR o, Z_SRW_diagnostic *d, int code, const char *details) { d->code = (char *) odr_malloc(o, 50); - sprintf(d->code, "info:srw/diagnostic/1/1/%d", code); + sprintf(d->code, "info:srw/diagnostic/1/%d", code); d->message = 0; if (details) d->details = odr_strdup(o, details); diff --git a/src/zoom-c.c b/src/zoom-c.c index e161888..caeba59 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (c) 2000-2004, Index Data * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.21 2004-01-27 12:15:12 adam Exp $ + * $Id: zoom-c.c,v 1.22 2004-01-27 21:22:44 adam Exp $ * * ZOOM layer for C, connections, result sets, queries. */ @@ -90,10 +90,18 @@ static void set_dset_error (ZOOM_connection c, int error, 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); @@ -219,6 +227,7 @@ ZOOM_connection_create (ZOOM_options options) 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; @@ -471,6 +480,7 @@ ZOOM_connection_destroy(ZOOM_connection c) 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); @@ -922,7 +932,7 @@ static zoom_ret ZOOM_connection_send_init (ZOOM_connection c) ZOOM_options_get(c->options, "implementationName"), odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName)); - version = odr_strdup(c->odr_out, "$Revision: 1.21 $"); + version = odr_strdup(c->odr_out, "$Revision: 1.22 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; ireq->implementationVersion = odr_prepend(c->odr_out, @@ -2949,20 +2959,16 @@ static void handle_srw_response(ZOOM_connection c, } if (res->num_diagnostics > 0) { - const char *std_diag = "info:srw/diagnostic/1/1/"; const char *code = res->diagnostics[0].code; - const char *cp; - const char *category = code; - int code_int = 0; - - if (code && (cp = strrchr(code, '/'))) - code_int = atoi(cp+1); - if (code && !strncmp(code, std_diag, strlen(std_diag))) - category = "SRW"; - - if (category) - set_dset_error(c, code_int, category, + if (code) + { + int code_int = 0; + const char *cp; + if ((cp = strrchr(code, '/'))) + code_int = atoi(cp+1); + set_dset_error(c, code_int, code, res->diagnostics[0].details, 0); + } } nmem = odr_extract_mem(c->odr_in); nmem_transfer(resultset->odr->mem, nmem); @@ -3246,7 +3252,7 @@ ZOOM_connection_error_x (ZOOM_connection c, const char **cp, *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"; diff --git a/src/zoom-p.h b/src/zoom-p.h index d852feb..a991aaf 100644 --- a/src/zoom-p.h +++ b/src/zoom-p.h @@ -1,6 +1,6 @@ /* * Private C header for ZOOM C. - * $Id: zoom-p.h,v 1.2 2003-12-20 00:51:19 adam Exp $ + * $Id: zoom-p.h,v 1.3 2004-01-27 21:22:44 adam Exp $ */ #include @@ -33,7 +33,7 @@ struct ZOOM_connection_p { char *path; int error; char *addinfo; - const char *diagset; + char *diagset; int state; int mask; int reconnect_ok; diff --git a/ztest/ztest.c b/ztest/ztest.c index e7e815f..bd4459e 100644 --- a/ztest/ztest.c +++ b/ztest/ztest.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2004, Index Data. * See the file LICENSE for details. * - * $Id: ztest.c,v 1.61 2004-01-27 12:15:12 adam Exp $ + * $Id: ztest.c,v 1.62 2004-01-27 21:22:44 adam Exp $ */ /* @@ -437,7 +437,7 @@ int ztest_present (void *handle, bend_present_rr *rr) int ztest_fetch(void *handle, bend_fetch_rr *r) { char *cp; - r->errstring = 0; + r->last_in_set = 0; r->basename = "Default"; r->output_format = r->request_format;