From: Adam Dickmeiss Date: Sat, 8 Sep 2007 06:17:45 +0000 (+0000) Subject: Function ZOOM_record_get allows type_spec=schema in which case schema X-Git-Tag: YAZ.3.0.12~9 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=f9747584f933039d25a9ba450f362d61733d14ea;hp=d9654ed894daa49f6f2996df86d330322ee28643 Function ZOOM_record_get allows type_spec=schema in which case schema for record is returned. --- diff --git a/doc/zoom.xml b/doc/zoom.xml index 9a8a910..87089ee 100644 --- a/doc/zoom.xml +++ b/doc/zoom.xml @@ -20,7 +20,7 @@ ZOOM_options_set_int(opt, name, value) ZOOM_connection_scan1 (ZOOM_connection c, ZOOM_query startterm) ZOOM_query_cql2rpn(ZOOM_query s, const char *str, ZOOM_connection conn) --> - + ZOOM &zoom; is an acronym for 'Z39.50 Object-Orientation Model' and is @@ -752,6 +752,12 @@ ZOOM_query_cql2rpn(ZOOM_query s, const char *str, ZOOM_connection conn) const char *. + schema + The schema of the record is returned + as a C null-terminated string. Return type is + const char *. + + render The record is returned in a display friendly format. Upon completion buffer is returned diff --git a/src/zoom-c.c b/src/zoom-c.c index e364892..d96d1f5 100644 --- a/src/zoom-c.c +++ b/src/zoom-c.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-c.c,v 1.145 2007-09-06 12:40:53 mike Exp $ + * $Id: zoom-c.c,v 1.146 2007-09-08 06:17:45 adam Exp $ */ /** * \file zoom-c.c @@ -1353,7 +1353,7 @@ static zoom_ret ZOOM_connection_send_init(ZOOM_connection c) odr_prepend(c->odr_out, "ZOOM-C", ireq->implementationName)); - version = odr_strdup(c->odr_out, "$Revision: 1.145 $"); + version = odr_strdup(c->odr_out, "$Revision: 1.146 $"); if (strlen(version) > 10) /* check for unexpanded CVS strings */ version[strlen(version)-2] = '\0'; ireq->implementationVersion = @@ -2012,6 +2012,12 @@ ZOOM_API(const char *) *len = (npr->databaseName ? strlen(npr->databaseName) : 0); return npr->databaseName; } + else if (!strcmp(type, "schema")) + { + if (len) + *len = rec->schema ? strlen(rec->schema) : 0; + return rec->schema; + } else if (!strcmp(type, "syntax")) { const char *desc = 0; @@ -2185,7 +2191,8 @@ static size_t record_hash(int pos) static void record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr, int pos, - const char *syntax, const char *elementSetName) + const char *syntax, const char *elementSetName, + const char *schema) { ZOOM_record_cache rc; @@ -2209,7 +2216,8 @@ static void record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr, } } rc = (ZOOM_record_cache) odr_malloc(r->odr, sizeof(*rc)); - rc->rec.npr = npr; + rc->rec.npr = npr; + rc->rec.schema = schema ? odr_strdup(r->odr, schema) : 0; rc->rec.odr = 0; rc->rec.wrbuf_marc = 0; rc->rec.wrbuf_iconv = 0; @@ -2308,7 +2316,8 @@ static void handle_records(ZOOM_connection c, Z_Records *sr, for (i = 0; inum_records; i++) { record_cache_add(resultset, p->records[i], i + *start, - syntax, elementSetName); + syntax, elementSetName, + elementSetName); } *count -= i; if (*count < 0) @@ -2327,7 +2336,7 @@ static void handle_records(ZOOM_connection c, Z_Records *sr, Z_NamePlusRecord *myrec = zget_surrogateDiagRec(resultset->odr, 0, 14, 0); record_cache_add(resultset, myrec, *start, - syntax, elementSetName); + syntax, elementSetName, 0); } } else if (present_phase) @@ -2335,7 +2344,8 @@ static void handle_records(ZOOM_connection c, Z_Records *sr, /* present response and we didn't get any records! */ Z_NamePlusRecord *myrec = zget_surrogateDiagRec(resultset->odr, 0, 14, 0); - record_cache_add(resultset, myrec, *start, syntax, elementSetName); + record_cache_add(resultset, myrec, *start, syntax, elementSetName, + 0); } } } @@ -3873,7 +3883,8 @@ static void handle_srw_response(ZOOM_connection c, npr->u.databaseRecord->u.octet_aligned->len = npr->u.databaseRecord->u.octet_aligned->size = res->records[i].recordData_len; - record_cache_add(resultset, npr, pos, syntax, elementSetName); + record_cache_add(resultset, npr, pos, syntax, elementSetName, + res->records[i].recordSchema); } if (res->num_diagnostics > 0) set_SRU_error(c, &res->diagnostics[0]); diff --git a/src/zoom-p.h b/src/zoom-p.h index 5fd0b86..28a3de3 100644 --- a/src/zoom-p.h +++ b/src/zoom-p.h @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-p.h,v 1.22 2007-08-23 14:23:23 adam Exp $ + * $Id: zoom-p.h,v 1.23 2007-09-08 06:17:45 adam Exp $ */ /** * \file zoom-p.h @@ -129,6 +129,7 @@ struct ZOOM_record_p { WRBUF wrbuf_iconv; WRBUF wrbuf_opac; Z_NamePlusRecord *npr; + const char *schema; }; struct ZOOM_record_cache_p { diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index d25c674..1668367 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: zoomsh.c,v 1.48 2007-08-16 10:09:37 adam Exp $ + * $Id: zoomsh.c,v 1.49 2007-09-08 06:17:45 adam Exp $ */ /** \file zoomsh.c @@ -200,11 +200,13 @@ static void display_records(ZOOM_connection c, const char *render = ZOOM_record_get(rec, "render", &len); const char *opac_render = ZOOM_record_get(rec, "opac", &opac_len); const char *syntax = ZOOM_record_get(rec, "syntax", 0); + const char *schema = ZOOM_record_get(rec, "schema", 0); /* if rec is non-null, we got a record for display */ if (rec) { - printf("%d %s %s\n", - pos, (db ? db : "unknown"), syntax); + printf("%d database=%s syntax=%s schema=%s\n", + pos, (db ? db : "unknown"), syntax, + schema ? schema : "unknown"); if (render) fwrite(render, 1, len, stdout); printf("\n"); @@ -212,7 +214,6 @@ static void display_records(ZOOM_connection c, fwrite(opac_render, 1, opac_len, stdout); } } - } }