From 06e73cb9f6d59fc7a38f17636016f2daaed02548 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 24 Apr 2003 13:30:31 +0000 Subject: [PATCH] For GFS: schema for bend_fetch; displayTerm for bend_scan. --- CHANGELOG | 11 +++++++++++ include/yaz/backend.h | 6 +++++- server/seshigh.c | 45 ++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9cbc063..b66fd98 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,16 @@ Possible compatibility problems with earlier versions marked with '*'. +New member 'schema' in struct bend_fetch_rr which the name of requested +schema (SRW/SRU) for record (or NULL if none was given). The fetch +handler MAY set this to reflect the schema of the returned record. + +New member 'display_term' in struct scan_entry. GFS now sets member entries +and allocates scan entries to be filled by user scan handler. In previous +version, entries member was allocated by the scan handler. That still works, +but the GFS will ignore member display_term - assuming it was NOT set by +the handler. The fact that the GFS now allocates the entries both allows +for new members and makes a scan handler easier to write. + Fix CQL lex buffer overflow. SRW/SRU recordPacking. For SRW default recordPacking is string. For diff --git a/include/yaz/backend.h b/include/yaz/backend.h index f6dfbf6..d321de5 100644 --- a/include/yaz/backend.h +++ b/include/yaz/backend.h @@ -23,7 +23,7 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: backend.h,v 1.20 2003-03-24 22:26:50 adam Exp $ + * $Id: backend.h,v 1.21 2003-04-24 13:30:32 adam Exp $ */ #ifndef BACKEND_H @@ -95,6 +95,7 @@ typedef struct bend_fetch_rr { int errcode; /* 0==success */ char *errstring; /* system error string or NULL */ int surrogate_flag; /* surrogate diagnostic */ + char *schema; /* string record schema input/output */ } bend_fetch_rr; struct scan_entry { @@ -102,6 +103,7 @@ struct scan_entry { int occurrences; /* no of occurrences or -1 if error (see below) */ int errcode; /* Bib-1 diagnostic code; only used when occur.= -1 */ char *errstring; /* Additional string */ + char *display_term; }; typedef enum { @@ -122,6 +124,8 @@ typedef struct bend_scan_rr { int term_position; /* desired index of term in result list/returned */ int num_entries; /* number of entries requested/returned */ + /* scan term entries. The called handler does not have + to allocate this. Size of entries is num_entries (see above) */ struct scan_entry *entries; bend_scan_status status; int errcode; diff --git a/server/seshigh.c b/server/seshigh.c index 53ab94c..a2a28f9 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * - * $Id: seshigh.c,v 1.153 2003-04-18 15:11:04 adam Exp $ + * $Id: seshigh.c,v 1.154 2003-04-24 13:30:32 adam Exp $ */ /* @@ -515,6 +515,7 @@ static int srw_bend_fetch(association *assoc, int pos, rr.errcode = 0; rr.errstring = 0; rr.surrogate_flag = 0; + rr.schema = srw_req->recordSchema; if (!assoc->init->bend_fetch) return 1; @@ -526,9 +527,10 @@ static int srw_bend_fetch(association *assoc, int pos, record->recordData_buf = rr.record; record->recordData_len = rr.len; record->recordPosition = odr_intdup(o, pos); - record->recordSchema = 0; - if (srw_req->recordSchema) - record->recordSchema = odr_strdup(o, srw_req->recordSchema); + if (rr.schema) + record->recordSchema = odr_strdup(o, rr.schema); + else + record->recordSchema = 0; } return rr.errcode; } @@ -1753,8 +1755,8 @@ static Z_Records *pack_records(association *a, char *setname, int start, freq.output_format_raw = 0; freq.stream = a->encode; freq.print = a->print; - freq.surrogate_flag = 0; freq.referenceId = referenceId; + freq.schema = 0; (*a->init->bend_fetch)(a->backend, &freq); /* backend should be able to signal whether error is system-wide or only pertaining to current record */ @@ -2103,6 +2105,7 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd) oident *attset; bend_scan_rr *bsrr = (bend_scan_rr *) odr_malloc (assoc->encode, sizeof(*bsrr)); + struct scan_entry *save_entries; yaz_log(LOG_LOG, "Got ScanRequest"); @@ -2140,6 +2143,28 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd) bsrr->stream = assoc->encode; bsrr->print = assoc->print; bsrr->step_size = res->stepSize; + bsrr->entries = 0; + /* Note that version 2.0 of YAZ and older did not set entries .. + We do now. And when we do it's easier to extend the scan entry + We know that if the scan handler did set entries, it will + not know of new member display_term. + */ + if (bsrr->num_entries > 0) + { + int i; + bsrr->entries = odr_malloc(assoc->decode, sizeof(*bsrr->entries) * + bsrr->num_entries); + for (i = 0; inum_entries; i++) + { + bsrr->entries[i].term = 0; + bsrr->entries[i].occurrences = 0; + bsrr->entries[i].errcode = 0; + bsrr->entries[i].errstring = 0; + bsrr->entries[i].display_term = 0; + } + } + save_entries = bsrr->entries; /* save it so we can compare later */ + if (req->attributeSet && (attset = oid_getentbyoid(req->attributeSet)) && (attset->oclass == CLASS_ATTSET || attset->oclass == CLASS_GENERAL)) @@ -2181,6 +2206,16 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd) odr_malloc(assoc->encode, sizeof(*t)); t->suggestedAttributes = 0; t->displayTerm = 0; + if (save_entries == bsrr->entries && + bsrr->entries[i].display_term) + { + /* the entries was NOT set by the handler. So it's + safe to test for new member display_term. It is + NULL'ed by us. + */ + t->displayTerm = odr_strdup(assoc->encode, + bsrr->entries[i].display_term); + } t->alternativeTerm = 0; t->byAttributes = 0; t->otherTermInfo = 0; -- 1.7.10.4