X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fzoom-c.c;h=9ddd781b154034f5453b35aabc963bba8c3cefd6;hb=f87d2eee00acc830ada9ee98c347f3d1415ea74b;hp=da9ca8b3e8abb7348f0c665eb105b2ee2506e54f;hpb=c6e47cbbff56f39f6d81b079ebaeac41d793d4d9;p=yaz-moved-to-github.git diff --git a/src/zoom-c.c b/src/zoom-c.c index da9ca8b..9ddd781 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.1 2003-10-27 12:21:36 adam Exp $ + * $Id: zoom-c.c,v 1.6 2003-11-25 09:50:35 mike Exp $ * * ZOOM layer for C, connections, result sets, queries. */ @@ -544,7 +544,12 @@ ZOOM_connection_search(ZOOM_connection c, ZOOM_query q) r->start = ZOOM_options_get_int(r->options, "start", 0); r->count = ZOOM_options_get_int(r->options, "count", 0); - r->step = ZOOM_options_get_int(r->options, "step", 0); + { + /* If "presentChunk" is defined use that; otherwise "step" */ + const char *cp = ZOOM_options_get (r->options, "presentChunk"); + r->step = ZOOM_options_get_int(r->options, + (cp != 0 ? "presentChunk": "step"), 0); + } r->piggyback = ZOOM_options_get_bool (r->options, "piggyback", 1); cp = ZOOM_options_get (r->options, "setname"); if (cp) @@ -884,7 +889,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 +909,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 +931,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.6 $") + 2 + + (impver ? strlen(impver) : 0)); + strcpy (ireq->implementationVersion, ""); + if (impver) + { + strcat (ireq->implementationVersion, impver); + strcat (ireq->implementationVersion, "/"); + } + strcat (ireq->implementationVersion, "$Revision: 1.6 $"); + *ireq->maximumRecordSize = ZOOM_options_get_int (c->options, "maximumRecordSize", 1024*1024); *ireq->preferredMessageSize = @@ -1025,7 +1053,7 @@ static zoom_ret send_srw (ZOOM_connection c, Z_SRW_PDU *sr) memcpy (h, cp0, cp1 - cp0); h[cp1-cp0] = '\0'; z_HTTP_header_add(c->odr_out, &gdu->u.HTTP_Request->headers, - "host", h); + "Host", h); } } @@ -2127,7 +2155,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 +2180,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); @@ -2511,6 +2570,16 @@ static void handle_apdu (ZOOM_connection c, Z_APDU *apdu) { case Z_APDU_initResponse: initrs = apdu->u.initResponse; + ZOOM_connection_option_set(c, "serverImplementationId", + initrs->implementationId ? + initrs->implementationId : ""); + ZOOM_connection_option_set(c, "serverImplementationName", + initrs->implementationName ? + initrs->implementationName : ""); + ZOOM_connection_option_set(c, "serverImplementationVersion", + initrs->implementationVersion ? + initrs->implementationVersion : ""); + /* Set the three old options too, for old applications */ ZOOM_connection_option_set(c, "targetImplementationId", initrs->implementationId ? initrs->implementationId : "");