* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: d1_marc.c,v 1.22 2002-08-17 07:56:59 adam Exp $
+ * $Id: d1_marc.c,v 1.23 2002-08-19 21:09:10 adam Exp $
*/
}
if (selected && !field->u.tag.node_selected)
continue;
+
+ subf = field->child;
+ if (!subf)
+ continue;
+
len += 4 + p->length_data_entry + p->length_starting
+ p->length_implementation;
base_address += 3 + p->length_data_entry + p->length_starting
+ p->length_implementation;
- subf = field->child;
if (subf->which == DATA1N_data)
is00X = 1;
continue;
subf = field->child;
+ if (!subf)
+ continue;
if (subf->which == DATA1N_data)
is00X = 1;
* See the file LICENSE for details.
* Sebastian Hammer, Adam Dickmeiss
*
- * $Id: d1_read.c,v 1.47 2002-07-29 20:04:08 adam Exp $
+ * $Id: d1_read.c,v 1.48 2002-08-19 21:09:10 adam Exp $
*/
#include <assert.h>
*/
data1_node *get_parent_tag (data1_handle dh, data1_node *n)
{
- for (; n && n->which != DATA1N_root; n = n->parent)
- if (n->which == DATA1N_tag)
- return n;
+ if (data1_is_xmlmode(dh))
+ {
+ for (; n && n->which != DATA1N_root; n = n->parent)
+ if (n->which == DATA1N_tag && n->parent &&
+ n->parent->which != DATA1N_root)
+ return n;
+ }
+ else
+ {
+ for (; n && n->which != DATA1N_root; n = n->parent)
+ if (n->which == DATA1N_tag)
+ return n;
+ }
return 0;
}
{
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;
+ data1_element *e = 0;
res->u.tag.tag = data1_insert_string_n (dh, res, nmem, tag, len);
- if (partag)
- e = partag->u.tag.element;
- res->u.tag.element =
- data1_getelementbytagname (dh, at->root->u.root.absyn,
- e, res->u.tag.tag);
+ if (!partag) /* top tag? */
+ e = data1_getelementbytagname (dh, at->root->u.root.absyn,
+ 0 /* index as local */,
+ res->u.tag.tag);
+ else
+ {
+ /* only set element for known tags */
+ e = partag->u.tag.element;
+ if (e)
+ e = data1_getelementbytagname (dh, at->root->u.root.absyn,
+ e, res->u.tag.tag);
+ }
+ res->u.tag.element = e;
p = &res->u.tag.attributes;
while (attr && *attr)
{
data1_node *datn = 0;
data1_node *tagn = 0;
- if (partag)
+ if (!partag)
+ e = data1_getelementbytagname (dh, root->u.root.absyn, 0, tagname);
+ else
+ {
e = partag->u.tag.element;
- e = data1_getelementbytagname (dh, root->u.root.absyn, e, tagname);
+ if (e)
+ e = data1_getelementbytagname (dh, root->u.root.absyn, e, tagname);
+ }
if (local_allowed || e)
{
tagn = data1_mk_node2 (dh, m, DATA1N_tag, at);
data1_xattr *p;
for (p = n->u.tag.attributes; p; p = p->next)
{
- if (conv_item(m, t, wrbuf, p->value, strlen(p->value))
+ if (p->value &&
+ conv_item(m, t, wrbuf, p->value, strlen(p->value))
== 0)
{
wrbuf_puts (wrbuf, "");
/*
- * $Id: zoom-c.c,v 1.38 2002-07-29 19:51:34 adam Exp $
+ * $Id: zoom-c.c,v 1.39 2002-08-19 21:09:10 adam Exp $
*
* ZOOM layer for C, connections, result sets, queries.
*/
ZOOM_API(int)
ZOOM_event (int no, ZOOM_connection *cs)
{
+ int timeout = 5000;
#if HAVE_SYS_POLL_H
struct pollfd pollfds[1024];
ZOOM_connection poll_cs[1024];
#if HAVE_SYS_POLL_H
#else
- tv.tv_sec = 25;
- tv.tv_usec = 0;
-
FD_ZERO (&input);
FD_ZERO (&output);
FD_ZERO (&except);
#endif
+ yaz_log (LOG_LOG, "select begin");
nfds = 0;
for (i = 0; i<no; i++)
{
ZOOM_connection c = cs[i];
int fd, mask;
+ int this_timeout;
if (!c)
continue;
if (max_fd < fd)
max_fd = fd;
+ this_timeout = ZOOM_options_get_int (c->options, "timeout", -1);
+ if (this_timeout != -1 && this_timeout < timeout)
+ timeout = this_timeout;
+ yaz_log (LOG_LOG, "time_timeout = %d, p=%p, timeout=%d", this_timeout,
+ c, timeout);
#if HAVE_SYS_POLL_H
if (mask)
{
}
#endif
}
+ if (timeout >= 5000)
+ timeout = 30;
+
if (!nfds)
return 0;
+ yaz_log (LOG_LOG, "select with timeout %d", timeout);
+
#if HAVE_SYS_POLL_H
- r = poll (pollfds, nfds, 25000);
+ r = poll (pollfds, nfds, timeout * 1000);
for (i = 0; i<nfds; i++)
{
ZOOM_connection c = poll_cs[i];
}
}
#else
+ tv.tv_sec = timeout;
+ tv.tv_usec = 0;
yaz_log (LOG_DEBUG, "select start");
r = select (max_fd+1, &input, &output, &except, &tv);
yaz_log (LOG_DEBUG, "select stop, returned r=%d", r);