--- 1.8.6 2002/MM/DD
+Added function yaz_marc_decode that decodes MARC for line mode
+display or XML.
+
Fixed BER decoding of OPTIONAL CHOICE. The bug didn't affect the
Z39.50. But ISO/ILL was, however.
#!/bin/sh
-# $Id: buildconf.sh,v 1.7 2001-11-06 17:03:50 adam Exp $
+# $Id: buildconf.sh,v 1.8 2002-02-28 13:21:16 adam Exp $
aclocal
libtoolize --automake --force || exit 2
automake -a || exit 3
if [ -f config.cache ]; then
rm config.cache
fi
-util/cvs-date.tcl include/yaz/yaz-date.h
+#util/cvs-date.tcl include/yaz/yaz-date.h
<xsl:import href="/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/htmlhelp/htmlhelp.xsl"/>
<xsl:param name="suppress.navigation" select="0"/>
+<xsl:param name="use.id.as.filename" select="1"/>
+
</xsl:stylesheet>
/*
- * Copyright (c) 1995-2001, Index Data.
+ * Copyright (c) 1995-2002, Index Data.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation, in whole or in part, for any purpose, is hereby granted,
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Log: marcdisp.h,v $
- * Revision 1.4 2001-10-29 09:17:19 adam
- * New function marc_display_exl - used by YAZ client. Server returns
- * bad record on position 98 (for testing).
- *
- * Revision 1.3 2001/04/06 12:26:46 adam
- * Optional CCL module. Moved atoi_n to marcdisp.h from yaz-util.h.
- *
- * Revision 1.2 2000/02/28 11:20:06 adam
- * Using autoconf. New definitions: YAZ_BEGIN_CDECL/YAZ_END_CDECL.
- *
- * Revision 1.1 1999/11/30 13:47:11 adam
- * Improved installation. Moved header files to include/yaz.
- *
- * Revision 1.8 1997/09/24 13:35:45 adam
- * Added two members to data1_marctab to ease reading of weird MARC records.
- *
- * Revision 1.7 1997/09/04 07:57:51 adam
- * Definition of ISO2709 control characters to this file.
- *
- * Revision 1.6 1997/09/01 08:49:49 adam
- * New windows NT/95 port using MSV5.0. To export DLL functions the
- * YAZ_EXPORT modifier was added. Defined in yconfig.h.
- *
- * Revision 1.5 1997/05/14 06:53:40 adam
- * C++ support.
- *
- * Revision 1.4 1995/09/29 17:12:03 quinn
- * Smallish
- *
- * Revision 1.3 1995/09/27 15:02:47 quinn
- * Modified function heads & prototypes.
- *
- * Revision 1.2 1995/05/16 08:50:32 quinn
- * License, documentation, and memory fixes
- *
- * Revision 1.1 1995/04/10 10:28:28 quinn
- * Added copy of CCL.
- *
+ * $Id: marcdisp.h,v 1.5 2002-02-28 13:21:16 adam Exp $
*/
#ifndef MARCDISP_H
/*
- * Copyright (c) 1995-2000, Index Data.
+ * Copyright (c) 1995-2002, Index Data.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation, in whole or in part, for any purpose, is hereby granted,
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Log: wrbuf.h,v $
- * Revision 1.4 2001-10-23 21:00:19 adam
- * Old Z39.50 codecs gone. Added ZOOM. WRBUF MARC display util.
- *
- * Revision 1.3 2001/10/15 19:36:48 adam
- * New function marc_display_wrbuf.
- *
- * Revision 1.2 2000/02/28 11:20:06 adam
- * Using autoconf. New definitions: YAZ_BEGIN_CDECL/YAZ_END_CDECL.
- *
- * Revision 1.1 1999/11/30 13:47:11 adam
- * Improved installation. Moved header files to include/yaz.
- *
- * Revision 1.8 1999/11/03 09:05:56 adam
- * Implemented wrbuf_puts.
- *
- * Revision 1.7 1999/08/27 09:40:32 adam
- * Renamed logf function to yaz_log. Removed VC++ project files.
- *
- * Revision 1.6 1997/10/31 12:20:08 adam
- * Improved memory debugging for xmalloc/nmem.c. References to NMEM
- * instead of ODR in n ESPEC-1 handling in source d1_espec.c.
- * Bug fix: missing fclose in data1_read_espec1.
- *
- * Revision 1.5 1997/09/17 12:10:32 adam
- * YAZ version 1.4.
+ * $Id: wrbuf.h,v 1.5 2002-02-28 13:21:16 adam Exp $
*
*/
YAZ_EXPORT int marc_display_wrbuf (const char *buf, WRBUF wr, int debug,
int bsize);
+YAZ_EXPORT int yaz_marc_decode (const char *buf, WRBUF wr, int debug,
+ int bsize, int xml);
+
YAZ_END_CDECL
#endif
-## $Id: Makefile.am,v 1.18 2001-11-19 20:43:39 adam Exp $
+## $Id: Makefile.am,v 1.19 2002-02-28 13:21:16 adam Exp $
if ISTHR
extra=libyazthread.la
xmalloc.o: $(top_srcdir)/util/xmalloc.c
$(COMPILE) $(XMALLOC_FLAGS) -c $(top_srcdir)/util/xmalloc.c
-
libyaz_la_LIBADD=../odr/libodr.la \
../comstack/libcomstack.la ../server/libserver.la \
../util/libutil.la ../retrieval/libret.la \
* Copyright (c) 1995-2002, Index Data
* See the file LICENSE for details.
*
- * $Id: marcdisp.c,v 1.17 2002-02-01 14:50:29 adam Exp $
+ * $Id: marcdisp.c,v 1.18 2002-02-28 13:21:16 adam Exp $
*/
#if HAVE_CONFIG_H
#include <yaz/wrbuf.h>
#include <yaz/yaz-util.h>
-int marc_display_wrbuf (const char *buf, WRBUF wr, int debug,
- int bsize)
+int yaz_marc_decode (const char *buf, WRBUF wr, int debug, int bsize, int xml)
{
int entry_p;
int record_length;
memcpy (tag, buf+entry_p, 3);
entry_p += 3;
tag[3] = '\0';
- if (debug)
- wrbuf_puts (wr, "Tag: ");
- wrbuf_puts (wr, tag);
- wrbuf_puts (wr, " ");
+ if (xml)
+ {
+ wrbuf_puts (wr, "<field name=\"");
+ wrbuf_puts (wr, tag);
+ wrbuf_puts (wr, "\"");
+ }
+ else
+ {
+ if (debug)
+ wrbuf_puts (wr, "Tag: ");
+ wrbuf_puts (wr, tag);
+ wrbuf_puts (wr, " ");
+ }
data_length = atoi_n (buf+entry_p, length_data_entry);
entry_p += length_data_entry;
data_offset = atoi_n (buf+entry_p, length_starting);
if (debug)
wrbuf_puts (wr, " Ind: ");
for (j = 0; j<indicator_length; j++, i++)
- wrbuf_putc (wr, buf[i]);
+ {
+ if (xml)
+ {
+ char nostr[30];
+ sprintf (nostr, " indicator%d=\"%c\"", j+1, buf[i]);
+ wrbuf_puts (wr, nostr);
+ }
+ else
+ wrbuf_putc (wr, buf[i]);
+ }
}
- if (debug)
- wrbuf_puts (wr, " Fields: ");
+ if (xml)
+ {
+ wrbuf_puts (wr, ">");
+ if (identifier_flag)
+ wrbuf_puts (wr, "\n");
+ }
+ else
+ {
+ if (debug)
+ wrbuf_puts (wr, " Fields: ");
+ }
while (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS && i < end_offset)
{
if (identifier_flag)
{
i++;
- wrbuf_puts (wr, " $");
- for (j = 1; j<identifier_length; j++, i++)
- wrbuf_putc (wr, buf[i]);
- wrbuf_putc (wr, ' ');
+ if (xml)
+ {
+ wrbuf_puts (wr, " <field name=\"");
+ for (j = 1; j<identifier_length; j++, i++)
+ wrbuf_putc (wr, buf[i]);
+ wrbuf_puts (wr, "\">");
+ }
+ else
+ {
+ wrbuf_puts (wr, " $");
+ for (j = 1; j<identifier_length; j++, i++)
+ wrbuf_putc (wr, buf[i]);
+ wrbuf_putc (wr, ' ');
+ }
while (buf[i] != ISO2709_RS && buf[i] != ISO2709_IDFS &&
buf[i] != ISO2709_FS && i < end_offset)
{
wrbuf_putc (wr, buf[i]);
i++;
}
+ if (xml)
+ wrbuf_puts (wr, "</field>\n");
}
else
{
i++;
}
}
- wrbuf_putc (wr, '\n');
+ if (!xml)
+ wrbuf_putc (wr, '\n');
if (i < end_offset)
- wrbuf_puts (wr, "-- separator but not at end of field\n");
+ wrbuf_puts (wr, " <!-- separator but not at end of field -->\n");
if (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
- wrbuf_puts (wr, "-- no separator at end of field\n");
+ wrbuf_puts (wr, " <!-- no separator at end of field -->\n");
+ if (xml)
+ wrbuf_puts (wr, "</field>\n");
}
wrbuf_puts (wr, "");
return record_length;
}
+int marc_display_wrbuf (const char *buf, WRBUF wr, int debug,
+ int bsize)
+{
+ return yaz_marc_decode (buf, wr, debug, bsize, 0);
+}
+
int marc_display_exl (const char *buf, FILE *outf, int debug, int length)
{
int record_length;
return record_length;
}
-
int marc_display_ex (const char *buf, FILE *outf, int debug)
{
return marc_display_exl (buf, outf, debug, -1);
/*
- * $Id: zoom-c.c,v 1.23 2002-01-28 09:27:48 adam Exp $
+ * $Id: zoom-c.c,v 1.24 2002-02-28 13:21:16 adam Exp $
*
* ZOOM layer for C, connections, result sets, queries.
*/
}
return "none";
}
- else if (!strcmp (type, "render"))
+ else if (!strcmp (type, "render") &&
+ npr->which == Z_NamePlusRecord_databaseRecord)
{
- if (npr->which == Z_NamePlusRecord_databaseRecord)
- {
- Z_External *r = (Z_External *) npr->u.databaseRecord;
- oident *ent = oid_getentbyoid(r->direct_reference);
-
- if (r->which == Z_External_sutrs)
- {
- *len = r->u.sutrs->len;
- return (const char *) r->u.sutrs->buf;
- }
- else if (r->which == Z_External_octet)
- {
- switch (ent->value)
- {
- case VAL_SOIF:
- case VAL_HTML:
- case VAL_SUTRS:
- break;
- case VAL_TEXT_XML:
- case VAL_APPLICATION_XML:
- break;
- default:
- if (!rec->wrbuf_marc)
- rec->wrbuf_marc = wrbuf_alloc();
- wrbuf_rewind (rec->wrbuf_marc);
- if (marc_display_wrbuf ((const char *)
- r->u.octet_aligned->buf,
- rec->wrbuf_marc, 0,
- r->u.octet_aligned->len) > 0)
- {
- *len = wrbuf_len(rec->wrbuf_marc);
- return wrbuf_buf(rec->wrbuf_marc);
- }
- }
- *len = r->u.octet_aligned->len;
- return (const char *) r->u.octet_aligned->buf;
- }
- else if (r->which == Z_External_grs1)
- {
- *len = 5;
- return "GRS-1";
- }
- }
+ Z_External *r = (Z_External *) npr->u.databaseRecord;
+ oident *ent = oid_getentbyoid(r->direct_reference);
+
+ if (r->which == Z_External_sutrs)
+ {
+ *len = r->u.sutrs->len;
+ return (const char *) r->u.sutrs->buf;
+ }
+ else if (r->which == Z_External_octet)
+ {
+ switch (ent->value)
+ {
+ case VAL_SOIF:
+ case VAL_HTML:
+ case VAL_SUTRS:
+ break;
+ case VAL_TEXT_XML:
+ case VAL_APPLICATION_XML:
+ break;
+ default:
+ if (!rec->wrbuf_marc)
+ rec->wrbuf_marc = wrbuf_alloc();
+ wrbuf_rewind (rec->wrbuf_marc);
+ if (yaz_marc_decode ((const char *)
+ r->u.octet_aligned->buf,
+ rec->wrbuf_marc, 0,
+ r->u.octet_aligned->len,
+ 0) > 0)
+ {
+ *len = wrbuf_len(rec->wrbuf_marc);
+ return wrbuf_buf(rec->wrbuf_marc);
+ }
+ }
+ *len = r->u.octet_aligned->len;
+ return (const char *) r->u.octet_aligned->buf;
+ }
+ else if (r->which == Z_External_grs1)
+ {
+ *len = 5;
+ return "GRS-1";
+ }
+ return 0;
+ }
+ else if (!strcmp (type, "xml") &&
+ npr->which == Z_NamePlusRecord_databaseRecord)
+ {
+ Z_External *r = (Z_External *) npr->u.databaseRecord;
+ oident *ent = oid_getentbyoid(r->direct_reference);
+
+ if (r->which == Z_External_sutrs)
+ {
+ *len = r->u.sutrs->len;
+ return (const char *) r->u.sutrs->buf;
+ }
+ else if (r->which == Z_External_octet)
+ {
+ switch (ent->value)
+ {
+ case VAL_SOIF:
+ case VAL_HTML:
+ case VAL_SUTRS:
+ break;
+ case VAL_TEXT_XML:
+ case VAL_APPLICATION_XML:
+ break;
+ default:
+ if (!rec->wrbuf_marc)
+ rec->wrbuf_marc = wrbuf_alloc();
+ wrbuf_rewind (rec->wrbuf_marc);
+ if (yaz_marc_decode ((const char *)
+ r->u.octet_aligned->buf,
+ rec->wrbuf_marc, 0,
+ r->u.octet_aligned->len,
+ 1) > 0)
+ {
+ *len = wrbuf_len(rec->wrbuf_marc);
+ return wrbuf_buf(rec->wrbuf_marc);
+ }
+ }
+ *len = r->u.octet_aligned->len;
+ return (const char *) r->u.octet_aligned->buf;
+ }
+ else if (r->which == Z_External_grs1)
+ {
+ *len = 5;
+ return "GRS-1";
+ }
return 0;
}
else if (!strcmp (type, "raw"))
/*
- * $Id: zoomtst5.c,v 1.8 2002-02-20 14:40:42 adam Exp $
+ * $Id: zoomtst5.c,v 1.9 2002-02-28 13:21:16 adam Exp $
*
* Asynchronous multi-target client doing search, sort and present
*/
/* get database for record and record itself at pos */
db = ZOOM_record_get (rec, "database", 0);
- str = ZOOM_record_get (rec, "render", &len);
+ str = ZOOM_record_get (rec, "xml", &len);
syntax = ZOOM_record_get (rec, "syntax", &len);
/* if rec is non-null, we got a record for display */
if (str)