X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fzoom-c.c;h=492c19052c59d75090bf8088330b708bb1a1244a;hb=8d92137c228ec24df2d62a8039635bb8ad19558d;hp=8b14d05105358aae4a54124ed4114f55a36976f1;hpb=accf4ae2bea381ba902f2058e8182510f96a0b5d;p=yaz-moved-to-github.git diff --git a/src/zoom-c.c b/src/zoom-c.c index 8b14d05..492c190 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (c) 2000-2003, Index Data * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.2 2003-11-02 17:58:16 adam Exp $ + * $Id: zoom-c.c,v 1.4 2003-11-19 19:07:26 adam Exp $ * * ZOOM layer for C, connections, result sets, queries. */ @@ -884,7 +884,7 @@ static zoom_ret send_APDU (ZOOM_connection c, Z_APDU *a) static zoom_ret ZOOM_connection_send_init (ZOOM_connection c) { - const char *impname; + const char *impid, *impname, *impver; Z_APDU *apdu = zget_APDU(c->odr_out, Z_APDU_initRequest); Z_InitRequest *ireq = apdu->u.initRequest; Z_IdAuthentication *auth = (Z_IdAuthentication *) @@ -904,6 +904,17 @@ static zoom_ret ZOOM_connection_send_init (ZOOM_connection c) ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_2); ODR_MASK_SET(ireq->protocolVersion, Z_ProtocolVersion_3); + impid = ZOOM_options_get (c->options, "implementationId"); + ireq->implementationId = + (char *) odr_malloc (c->odr_out, 15 + (impid ? strlen(impid) : 0)); + strcpy (ireq->implementationId, ""); + if (impid) + { + strcat (ireq->implementationId, impid); + strcat (ireq->implementationId, "/"); + } + strcat (ireq->implementationId, "81"); /* Index's implementor ID */ + impname = ZOOM_options_get (c->options, "implementationName"); ireq->implementationName = (char *) odr_malloc (c->odr_out, 15 + (impname ? strlen(impname) : 0)); @@ -915,6 +926,18 @@ static zoom_ret ZOOM_connection_send_init (ZOOM_connection c) } strcat (ireq->implementationName, "ZOOM-C/YAZ"); + impver = ZOOM_options_get (c->options, "implementationVersion"); + ireq->implementationVersion = + (char *) odr_malloc (c->odr_out, strlen("$Revision: 1.4 $") + 2 + + (impver ? strlen(impver) : 0)); + strcpy (ireq->implementationVersion, ""); + if (impver) + { + strcat (ireq->implementationVersion, impver); + strcat (ireq->implementationVersion, "/"); + } + strcat (ireq->implementationVersion, "$Revision: 1.4 $"); + *ireq->maximumRecordSize = ZOOM_options_get_int (c->options, "maximumRecordSize", 1024*1024); *ireq->preferredMessageSize = @@ -2127,7 +2150,7 @@ ZOOM_scanset_size (ZOOM_scanset scan) ZOOM_API(const char *) ZOOM_scanset_term (ZOOM_scanset scan, size_t pos, - int *occ, int *len) + int *occ, int *len) { const char *term = 0; size_t noent = ZOOM_scanset_size (scan); @@ -2152,6 +2175,37 @@ ZOOM_scanset_term (ZOOM_scanset scan, size_t pos, } ZOOM_API(const char *) +ZOOM_scanset_display_term (ZOOM_scanset scan, size_t pos, + int *occ, int *len) +{ + const char *term = 0; + size_t noent = ZOOM_scanset_size (scan); + Z_ScanResponse *res = scan->scan_response; + + *len = 0; + *occ = 0; + if (pos >= noent) + return 0; + if (res->entries->entries[pos]->which == Z_Entry_termInfo) + { + Z_TermInfo *t = res->entries->entries[pos]->u.termInfo; + + if (t->displayTerm) + { + term = (const char *) t->term->u.general->buf; + *len = strlen(term); + } + else if (t->term->which == Z_Term_general) + { + term = (const char *) t->term->u.general->buf; + *len = t->term->u.general->len; + } + *occ = t->globalOccurrences ? *t->globalOccurrences : 0; + } + return term; +} + +ZOOM_API(const char *) ZOOM_scanset_option_get (ZOOM_scanset scan, const char *key) { return ZOOM_options_get (scan->options, key);