Possible compatibility problems with earlier versions marked with '*'.
+
--- 1.8.7 2002/MM/DD
+XML reader for data1 (EXPAT).
+
Fixed bug in ZOOM connect that occurred on OpenBSD (maybe others). Patch
by Oleg Kolobov.
#!/bin/sh
-# $Id: buildconf.sh,v 1.10 2002-03-16 11:46:18 adam Exp $
+# $Id: buildconf.sh,v 1.11 2002-05-13 14:13:37 adam Exp $
aclocal
libtoolize --automake --force
automake -a
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
dnl YAZ Toolkit, Index Data 1994-2001
dnl See the file LICENSE for details.
-dnl $Id: configure.in,v 1.72 2002-05-03 13:47:57 adam Exp $
+dnl $Id: configure.in,v 1.73 2002-05-13 14:13:37 adam Exp $
AC_INIT(include/yaz/yaz-version.h)
AM_INIT_AUTOMAKE(yaz, 1.8.7)
dnl
AC_SUBST(READLINE_LIBS)
+AC_SUBST(YAZ_CONF_CFLAGS)
dnl ------ Checking programs
AC_PROG_CC
AC_PROG_CPP
fi
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))
dnl
+dnl ------ EXPAT
+expat=yes
+AC_ARG_WITH(expat, [ --with-expat[=DIR] EXPAT library in DIR],[expat=$withval])
+if test "$expat" != "no"; then
+ xLIBS="$LIBS";
+ xCFLAGS="$CFLAGS";
+ if test "$expat" != "yes"; then
+ EXPAT_CFLAGS="-I$expat/include"
+ EXPAT_LIBS="-L$expat/lib"
+ CFLAGS="$EXPAT_CFLAGS $CFLAGS"
+ LIBS="$EXPAT_LIBS $LIBS"
+ fi
+ AC_CHECK_LIB(expat,XML_ParserCreate,[LIBS="$LIBS -lexpat"])
+ if test "$ac_cv_lib_expat_XML_ParserCreate" = "yes"; then
+ AC_CHECK_HEADERS(expat.h)
+ if test "$ac_cv_header_expat_h" = "yes"; then
+ YAZ_CONF_CFLAGS="$YAZ_CONF_CFLAGS -DYAZ_HAVE_EXPAT=1"
+ fi
+ else
+ LIBS="$xLIBS"
+ CFLAGS="$xCFLAGS"
+ fi
+fi
+dnl
dnl ------ Open SSL
openssl=no
AC_ARG_WITH(openssl, [ --with-openssl[=DIR] OpenSSL library in DIR], [openssl=$withval])
CFLAGS="$xCFLAGS"
fi
AM_CONDITIONAL(ISSSL, test $USE_SSL = "1")
+dnl
dnl ------ GNU Readline
READLINE_SHARED_LIBADD=""
AC_CHECK_LIB(ncurses, tgetent, [READLINE_SHARED_LIBADD="-lncurses"],
AC_CHECK_LIB(history, add_history, [READLINE_LIBS="$READLINE_LIBS -lhistory"])
if test "$ac_cv_lib_readline_readline" = "yes"; then
AC_CHECK_HEADERS(readline/readline.h readline/history.h)
- OLDLIBS=$LIBS
+ xLIBS=$LIBS
LIBS="$LIBS $READLINE_LIBS"
AC_TRY_LINK([
#include <stdio.h>
rl_completion_matches (0, 0);
}
],AC_DEFINE(HAVE_READLINE_RL_COMPLETION_MATCHES))
- LIBS=$OLDLIBS
+ LIBS=$xLIBS
fi
dnl ------ various functions
AC_CHECK_FUNCS(vsnprintf gettimeofday poll)
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Id: data1.h,v 1.9 2002-05-07 11:02:56 adam Exp $
+ * $Id: data1.h,v 1.10 2002-05-13 14:13:37 adam Exp $
*/
#ifndef DATA1_H
#define d1_isspace(c) strchr(" \r\n\t\f", c)
#define d1_isdigit(c) ((c) <= '9' && (c) >= '0')
-#define DATA1_USING_XATTR 1
-
YAZ_BEGIN_CDECL
#define data1_matchstr(s1, s2) yaz_matchstr(s1, s2)
data1_element *elements;
} data1_sub_elements;
-#if DATA1_USING_XATTR
typedef struct data1_xattr {
char *name;
char *value;
struct data1_xattr *next;
} data1_xattr;
-#endif
typedef struct data1_absyn
{
int get_bytes;
unsigned node_selected : 1;
unsigned make_variantlist : 1;
-#if DATA1_USING_XATTR
data1_xattr *attributes;
-#endif
} tag;
struct
int type, data1_node *parent);
YAZ_EXPORT data1_node *data1_mk_tag (data1_handle dh, NMEM nmem,
- const char *tag, data1_node *at);
+ const char *tag, const char **attr,
+ data1_node *at);
YAZ_EXPORT data1_node *data1_mk_tag_n (data1_handle dh, NMEM nmem,
const char *tag, size_t len,
+ const char **attr,
data1_node *at);
YAZ_EXPORT data1_node *data1_mk_text_n (data1_handle dh, NMEM mem,
NMEM m, const char *str, size_t len);
YAZ_EXPORT data1_node *data1_read_sgml (data1_handle dh, NMEM m,
const char *buf);
+YAZ_EXPORT data1_node *data1_read_xml (data1_handle dh,
+ int (*rf)(void *, char *, size_t),
+ void *fh, NMEM m);
YAZ_EXPORT void data1_absyn_trav (data1_handle dh, void *handle,
void (*fh)(data1_handle dh,
void *h, data1_absyn *a));
-## $Id: Makefile.am,v 1.5 2002-04-15 09:44:44 adam Exp $
+## $Id: Makefile.am,v 1.6 2002-05-13 14:13:37 adam Exp $
noinst_LTLIBRARIES=libret.la
libret_la_SOURCES = d1_handle.c d1_read.c d1_attset.c d1_tagset.c d1_absyn.c \
d1_grs.c d1_sutrs.c d1_varset.c d1_espec.c d1_doespec.c d1_map.c d1_marc.c \
- d1_write.c d1_expout.c d1_sumout.c d1_soif.c d1_prtree.c d1_if.c
+ d1_write.c d1_expout.c d1_sumout.c d1_soif.c d1_prtree.c d1_if.c d1_expat.c
AM_CPPFLAGS=-I$(top_srcdir)/include
--- /dev/null
+/*
+ * Copyright (c) 2002, Index Data.
+ * See the file LICENSE for details.
+ *
+ * $Id: d1_expat.c,v 1.1 2002-05-13 14:13:37 adam Exp $
+ */
+
+#if HAVE_EXPAT_H
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <yaz/xmalloc.h>
+#include <yaz/log.h>
+#include <yaz/data1.h>
+
+#include <expat.h>
+
+struct user_info {
+ data1_node *d1_stack[256];
+ int level;
+ data1_handle dh;
+ NMEM nmem;
+};
+
+static void cb_start (void *user, const char *el, const char **attr)
+{
+ struct user_info *ui = (struct user_info*) user;
+ if (ui->level)
+ {
+ ui->d1_stack[ui->level] = data1_mk_tag (ui->dh, ui->nmem, el, attr,
+ ui->d1_stack[ui->level-1]);
+ }
+ else
+ {
+ ui->d1_stack[0] = data1_mk_root (ui->dh, ui->nmem, el);
+ }
+ ui->level++;
+}
+
+static void cb_end (void *user, const char *el)
+{
+ struct user_info *ui = (struct user_info*) user;
+
+ ui->level--;
+}
+
+static void cb_chardata (void *user, const char *s, int len)
+{
+ struct user_info *ui = (struct user_info*) user;
+ ui->d1_stack[ui->level] = data1_mk_text_n (ui->dh, ui->nmem, s, len,
+ ui->d1_stack[ui->level -1]);
+}
+
+#define XML_CHUNK 1024
+
+data1_node *data1_read_xml (data1_handle dh,
+ int (*rf)(void *, char *, size_t), void *fh,
+ NMEM m)
+{
+ XML_Parser parser;
+ struct user_info uinfo;
+ int done = 0;
+
+ uinfo.level = 0;
+ uinfo.dh = dh;
+ uinfo.d1_stack[0] = 0;
+ uinfo.nmem = m;
+
+ parser = XML_ParserCreate (0 /* encoding */);
+
+ XML_SetElementHandler (parser, cb_start, cb_end);
+ XML_SetCharacterDataHandler (parser, cb_chardata);
+ XML_SetUserData (parser, &uinfo);
+
+ while (!done)
+ {
+ int r;
+ void *buf = XML_GetBuffer (parser, XML_CHUNK);
+ if (!buf)
+ {
+ /* error */
+ return 0;
+ }
+ r = (*rf)(fh, buf, XML_CHUNK);
+ if (r < 0)
+ {
+ /* error */
+ return 0;
+ }
+ else if (r == 0)
+ done = 1;
+ XML_ParseBuffer (parser, r, done);
+ }
+ XML_ParserFree (parser);
+ return uinfo.d1_stack[0];
+}
+
+#endif
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: d1_grs.c,v $
- * Revision 1.19 2002-04-15 09:06:30 adam
+ * Revision 1.20 2002-05-13 14:13:37 adam
+ * XML reader for data1 (EXPAT)
+ *
+ * Revision 1.19 2002/04/15 09:06:30 adam
* Fix explain tags for XML writer
*
* Revision 1.18 2002/04/12 14:40:07 adam
break;
case DATA1I_text:
toget = n->u.data.len;
- if (p->u.tag.get_bytes > 0 && p->u.tag.get_bytes < toget)
+ if (p && p->u.tag.get_bytes > 0 && p->u.tag.get_bytes < toget)
toget = p->u.tag.get_bytes;
res->which = Z_ElementData_string;
res->u.string = (char *)odr_malloc(o, toget+1);
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: d1_prtree.c,v 1.7 2002-01-26 19:20:25 adam Exp $
+ * $Id: d1_prtree.c,v 1.8 2002-05-13 14:13:37 adam Exp $
*/
#include <yaz/log.h>
fprintf (out, "%*s", level, "");
switch (n->which)
{
- case DATA1N_root:
- fprintf (out, "root abstract syntax=%s\n", n->u.root.type);
- break;
+ case DATA1N_root:
+ fprintf (out, "root abstract syntax=%s\n", n->u.root.type);
+ break;
case DATA1N_tag:
fprintf (out, "tag type=%s\n", n->u.tag.tag);
-#if DATA1_USING_XATTR
if (n->u.tag.attributes)
{
data1_xattr *xattr = n->u.tag.attributes;
fprintf (out, " %s=%s ", xattr->name, xattr->value);
fprintf (out, "\n");
}
-#endif
break;
case DATA1N_data:
fprintf (out, "data type=");
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: d1_read.c,v 1.41 2002-05-07 11:02:56 adam Exp $
+ * $Id: d1_read.c,v 1.42 2002-05-13 14:13:37 adam Exp $
*/
#include <assert.h>
r->u.tag.node_selected = 0;
r->u.tag.make_variantlist = 0;
r->u.tag.get_bytes = -1;
-#if DATA1_USING_XATTR
r->u.tag.attributes = 0;
-#endif
break;
case DATA1N_root:
r->u.root.type = 0;
}
data1_node *data1_mk_tag_n (data1_handle dh, NMEM nmem,
- const char *tag, size_t len, data1_node *at)
+ const char *tag, size_t len, const char **attr,
+ data1_node *at)
{
data1_node *partag = get_parent_tag(dh, at);
data1_node *res = data1_mk_node2 (dh, nmem, DATA1N_tag, at);
data1_element *e = NULL;
+ data1_xattr **p;
res->u.tag.tag = data1_insert_string_n (dh, res, nmem, tag, len);
res->u.tag.element =
data1_getelementbytagname (dh, at->root->u.root.absyn,
e, res->u.tag.tag);
+ p = &res->u.tag.attributes;
+ while (attr && *attr)
+ {
+ *p = (data1_xattr*) nmem_malloc (nmem, sizeof(**p));
+ (*p)->name = nmem_strdup (nmem, attr[0]);
+ (*p)->value = nmem_strdup (nmem, attr[1]);
+ p = &(*p)->next;
+ }
+ *p = 0;
return res;
}
data1_node *data1_mk_tag (data1_handle dh, NMEM nmem,
- const char *tag, data1_node *at)
+ const char *tag, const char **attr, data1_node *at)
{
- return data1_mk_tag_n (dh, nmem, tag, strlen(tag), at);
+ return data1_mk_tag_n (dh, nmem, tag, strlen(tag), attr, at);
}
data1_node *data1_search_tag (data1_handle dh, data1_node *n,
{
data1_node *node = data1_search_tag (dh, at->child, tag);
if (!node)
- node = data1_mk_tag (dh, nmem, tag, at);
+ node = data1_mk_tag (dh, nmem, tag, 0 /* attr */, at);
else
node->child = node->last_child = 0;
return node;
}
-#if DATA1_USING_XATTR
data1_xattr *data1_read_xattr (data1_handle dh, NMEM m,
int (*get_byte)(void *fh), void *fh,
WRBUF wrbuf, int *ch)
*ch = c;
return p_first;
}
-#endif
/*
* Ugh. Sometimes functions just grow and grow on you. This one reads a
if (c == '<') /* beginning of tag */
{
-#if DATA1_USING_XATTR
data1_xattr *xattr;
-#endif
+
char tag[64];
char args[256];
int null_tag = 0;
c = (*get_byte)(fh);
}
tag[i] = '\0';
-#if DATA1_USING_XATTR
xattr = data1_read_xattr (dh, m, get_byte, fh, wrbuf, &c);
args[0] = '\0';
-#else
- while (d1_isspace(c))
- c = (*get_byte)(fh);
- for (i = 0; c && c != '>' && c != '/'; c = (*get_byte)(fh))
- if (i < (sizeof(args)-1))
- args[i++] = c;
- args[i] = '\0';
-#endif
if (c == '/')
{ /* <tag attrs/> or <tag/> */
null_tag = 1;
data1_insert_string (dh, res, m, args + val_offset);
}
}
- else /* tag.. acquire our element in the abstract syntax */
- res = data1_mk_tag (dh, m, tag, parent);
+ else
+ {
+ /* tag.. acquire our element in the abstract syntax */
+ res = data1_mk_tag (dh, m, tag, 0 /* attr */, parent);
+ res->u.tag.attributes = xattr;
+ }
d1_stack[level] = res;
d1_stack[level+1] = 0;
if (level < 250 && !null_tag)
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: d1_write.c,v 1.10 2002-04-15 09:06:30 adam Exp $
+ * $Id: d1_write.c,v 1.11 2002-05-13 14:13:37 adam Exp $
*/
#include <string.h>
}
else
{
-#if DATA1_USING_XATTR
data1_xattr *p;
-#endif
+
sprintf (line, "%*s<", col, "");
wrbuf_puts (b, line);
wrbuf_puts (b, tag);
-#if DATA1_USING_XATTR
for (p = c->u.tag.attributes; p; p = p->next)
{
wrbuf_putc (b, ' ');
wrbuf_puts (b, p->value);
wrbuf_putc (b, '"');
}
-#endif
wrbuf_puts(b, ">\n");
if (nodetoidsgml(c, select, b, (col > 40) ? 40 : col+2) < 0)
return -1;
#!/bin/sh
-# $Id: yaz-config.in,v 1.12 2002-03-18 12:22:00 adam Exp $
+# $Id: yaz-config.in,v 1.13 2002-05-13 14:13:37 adam Exp $
yazprefix=@prefix@
yaz_echo_cflags=no
yaz_echo_libs=no
fi
fi
+YAZINC="$YAZINC @YAZ_CONF_CFLAGS@"
+
if test "$lib_thread" = "yes"; then
YAZINC="$YAZINC @CFLAGSTHREADS@"
fi