New WRBUF printf utility: wrbuf_printf.
Possible compatibility problems with earlier versions marked with '*'.
+Add GRS-1 render for ZOOM using same format as yaz-client.
+
--- 1.9.1 2002/10/05
Added man pages: yaz-client(1), yaz-ztest(8), yaz(7), zoomsh(1).
* Copyright (c) 1995-2002, Index Data
* See the file LICENSE for details.
*
- * $Id: client.c,v 1.172 2002-10-04 19:05:36 adam Exp $
+ * $Id: client.c,v 1.173 2002-10-22 10:05:36 adam Exp $
*/
#include <stdio.h>
/* SEARCH SERVICE ------------------------------ */
static void display_record(Z_External *r);
-static void display_variant(Z_Variant *v, int level)
-{
- int i;
-
- for (i = 0; i < v->num_triples; i++)
- {
- printf("%*sclass=%d,type=%d", level * 4, "", *v->triples[i]->zclass,
- *v->triples[i]->type);
- if (v->triples[i]->which == Z_Triple_internationalString)
- printf(",value=%s\n", v->triples[i]->value.internationalString);
- else
- printf("\n");
- }
-}
-
-static void display_grs1(Z_GenericRecord *r, int level)
-{
- int i;
-
- if (!r)
- {
- return;
- }
- for (i = 0; i < r->num_elements; i++)
- {
- Z_TaggedElement *t;
-
- printf("%*s", level * 4, "");
- t = r->elements[i];
- printf("(");
- if (t->tagType)
- printf("%d,", *t->tagType);
- else
- printf("?,");
- if (t->tagValue->which == Z_StringOrNumeric_numeric)
- printf("%d) ", *t->tagValue->u.numeric);
- else
- printf("%s) ", t->tagValue->u.string);
- if (t->content->which == Z_ElementData_subtree)
- {
- if (!t->content->u.subtree)
- printf (" (no subtree)\n");
- else
- {
- printf("\n");
- display_grs1(t->content->u.subtree, level+1);
- }
- }
- else if (t->content->which == Z_ElementData_string)
- printf("%s\n", t->content->u.string);
- else if (t->content->which == Z_ElementData_numeric)
- printf("%d\n", *t->content->u.numeric);
- else if (t->content->which == Z_ElementData_oid)
- {
- int *ip = t->content->u.oid;
- oident *oent;
-
- if ((oent = oid_getentbyoid(t->content->u.oid)))
- printf("OID: %s\n", oent->desc);
- else
- {
- printf("{");
- while (ip && *ip >= 0)
- printf(" %d", *(ip++));
- printf(" }\n");
- }
- }
- else if (t->content->which == Z_ElementData_noDataRequested)
- printf("[No data requested]\n");
- else if (t->content->which == Z_ElementData_elementEmpty)
- printf("[Element empty]\n");
- else if (t->content->which == Z_ElementData_elementNotThere)
- printf("[Element not there]\n");
- else if (t->content->which == Z_ElementData_date)
- printf("Date: %s\n", t->content->u.date);
- else if (t->content->which == Z_ElementData_ext)
- {
- printf ("External\n");
- display_record (t->content->u.ext);
- }
- else
- printf("? type = %d\n",t->content->which);
- if (t->appliedVariant)
- display_variant(t->appliedVariant, level+1);
- if (t->metaData && t->metaData->supportedVariants)
- {
- int c;
-
- printf("%*s---- variant list\n", (level+1)*4, "");
- for (c = 0; c < t->metaData->num_supportedVariants; c++)
- {
- printf("%*svariant #%d\n", (level+1)*4, "", c);
- display_variant(t->metaData->supportedVariants[c], level + 2);
- }
- }
- }
-}
-
-
static void print_record(const unsigned char *buf, size_t len)
{
size_t i = len;
}
else if (ent && ent->value == VAL_GRS1)
{
+ WRBUF w;
if (r->which != Z_External_grs1)
{
printf("Expecting single GRS type for GRS.\n");
return;
}
- display_grs1(r->u.grs1, 0);
+ w = wrbuf_alloc();
+ yaz_display_grs1(w, r->u.grs1, 0);
+ puts (wrbuf_buf(w));
+ wrbuf_free(w, 1);
}
else
{
/*
- * Copyright (c) 1998-2001, Index Data
+ * Copyright (c) 1998-2002, Index Data
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Log: proto.h,v $
- * Revision 1.3 2002-08-29 19:36:09 ja7
- * Added
- * YAZ_EXPORT const char* yaz_z3950_oid_value_to_str(oid_value ov, oid_class oc);
- * Used for gettting ui friendly names for oid_value's
- *
- * Revision 1.2 2002/02/11 23:25:26 adam
- * Rustam's patch
- *
- * Revision 1.1 2001/10/23 21:00:19 adam
- * Old Z39.50 codecs gone. Added ZOOM. WRBUF MARC display util.
- *
- * Revision 1.7 2001/09/24 21:51:55 adam
- * New Z39.50 OID utilities: yaz_oidval_to_z3950oid, yaz_str_to_z3950oid
- * and yaz_z3950oid_to_str.
- *
- * Revision 1.6 2001/09/19 10:19:07 adam
- * Z_SortCase_caseInsensitive was set to wrong value.
- *
- * Revision 1.5 2001/05/17 14:16:15 adam
- * Added EXTERNAL handling for item update0 (1.0).
- *
- * Revision 1.4 2000/03/14 09:19:49 ian
- * Added admin extended service encoders & decoders.
- *
- * Revision 1.3 2000/02/28 11:20:06 adam
- * Using autoconf. New definitions: YAZ_BEGIN_CDECL/YAZ_END_CDECL.
- *
- * Revision 1.2 1999/12/16 23:36:19 adam
- * Implemented ILL protocol. Minor updates ASN.1 compiler.
- *
- * Revision 1.1 1999/11/30 13:47:11 adam
- * Improved installation. Moved header files to include/yaz.
- *
- * Revision 1.2 1999/06/09 10:52:11 adam
- * Added YAZ_EXPORT.
- *
- * Revision 1.1 1999/06/08 13:11:55 adam
- * Fixed problem with proto.h.
- *
- * Revision 1.2 1999/04/20 10:37:04 adam
- * Updated for ODR - added name parameter.
- *
- * Revision 1.1 1998/03/31 16:04:05 adam
- * First version of proto.h which is almost compatible with the old one.
- *
+ * $Id: proto.h,v 1.4 2002-10-22 10:05:36 adam Exp $
*/
#ifndef Z_PROTO_H
#define Z_PROTO_H
#include <yaz/zes-update0.h>
#include <yaz/z-charneg.h>
#include <yaz/oid.h>
+#include <yaz/wrbuf.h>
YAZ_BEGIN_CDECL
YAZ_EXPORT const char* yaz_z3950_oid_value_to_str(oid_value ov, oid_class oc);
+YAZ_EXPORT void yaz_display_grs1(WRBUF wrbuf, Z_GenericRecord *r, int flags);
+
YAZ_END_CDECL
#include <yaz/prt-ext.h>
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Id: wrbuf.h,v 1.5 2002-02-28 13:21:16 adam Exp $
+ * $Id: wrbuf.h,v 1.6 2002-10-22 10:05:36 adam Exp $
*
*/
YAZ_EXPORT int wrbuf_grow(WRBUF b, int minsize);
YAZ_EXPORT int wrbuf_write(WRBUF b, const char *buf, int size);
YAZ_EXPORT int wrbuf_puts(WRBUF b, const char *buf);
+YAZ_EXPORT void wrbuf_printf(WRBUF b, const char *fmt, ...);
#define wrbuf_len(b) ((b)->pos)
#define wrbuf_buf(b) ((b)->buf)
/*
- * Copyright (c) 1995-2000, Index Data.
+ * Copyright (c) 1995-2002, Index Data.
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Log: wrbuf.c,v $
- * Revision 1.9 2000-02-29 13:44:55 adam
- * Check for config.h (currently not generated).
- *
- * Revision 1.8 1999/11/30 13:47:12 adam
- * Improved installation. Moved header files to include/yaz.
- *
- * Revision 1.7 1999/11/03 09:05:56 adam
- * Implemented wrbuf_puts.
- *
- * Revision 1.6 1999/10/28 11:36:40 adam
- * wrbuf_write allows zero buffer length.
- *
- * Revision 1.5 1999/08/27 09:40:32 adam
- * Renamed logf function to yaz_log. Removed VC++ project files.
- *
- * Revision 1.4 1998/02/11 11:53:36 adam
- * Changed code so that it compiles as C++.
- *
- * Revision 1.3 1997/05/01 15:08:15 adam
- * Added log_mask_str_x routine.
- *
- * Revision 1.2 1995/11/01 13:55:06 quinn
- * Minor adjustments
- *
- * Revision 1.1 1995/10/06 08:51:25 quinn
- * Added Write-buffer.
- *
- *
+ * $Id: wrbuf.c,v 1.10 2002-10-22 10:05:36 adam Exp $
*/
/*
#include <stdlib.h>
#include <string.h>
+#include <stdarg.h>
#include <yaz/wrbuf.h>
(b->pos)--; /* don't include '\0' in count */
return 0;
}
+
+void wrbuf_printf(WRBUF b, const char *fmt, ...)
+{
+ va_list ap;
+ char buf[4096];
+
+ va_start(ap, fmt);
+#ifdef WIN32
+ _vsnprintf(buf, sizeof(buf)-1, fmt, ap);
+#else
+/* !WIN32 */
+#if HAVE_VSNPRINTF
+ vsnprintf(buf, sizeof(buf)-1, fmt, ap);
+#else
+ vsprintf(buf, fmt, ap);
+#endif
+#endif
+ wrbuf_puts (b, buf);
+
+ va_end(ap);
+}
+
-## $Id: Makefile.am,v 1.12 2002-09-16 18:45:14 adam Exp $
+## $Id: Makefile.am,v 1.13 2002-10-22 10:05:36 adam Exp $
noinst_LTLIBRARIES = libzutil.la
AM_CPPFLAGS=-I$(top_srcdir)/include
libzutil_la_SOURCES = zget.c yaz-ccl.c diagbib1.c logrpn.c \
otherinfo.c pquery.c sortspec.c z3950oid.c charneg.c \
- zoom-c.c zoom-opt.c zoom-p.h
+ zoom-c.c zoom-opt.c zoom-p.h grs1disp.c
/*
- * $Id: zoom-c.c,v 1.4 2002-10-04 11:23:50 adam Exp $
+ * $Id: zoom-c.c,v 1.5 2002-10-22 10:05:36 adam Exp $
*
* ZOOM layer for C, connections, result sets, queries.
*/
}
else if (r->which == Z_External_grs1)
{
- if (len) *len = 5;
- return "GRS-1";
+ if (!rec->wrbuf_marc)
+ rec->wrbuf_marc = wrbuf_alloc();
+ wrbuf_rewind (rec->wrbuf_marc);
+ yaz_display_grs1(rec->wrbuf_marc, r->u.grs1, 0);
+ if (len)
+ *len = wrbuf_len(rec->wrbuf_marc);
+ return wrbuf_buf(rec->wrbuf_marc);
}
return 0;
}