projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
idzebra-abs2dom part of DIST
[idzebra-moved-to-github.git]
/
data1
/
d1_expout.c
diff --git
a/data1/d1_expout.c
b/data1/d1_expout.c
index
ca6862f
..
9b82aa7
100644
(file)
--- a/
data1/d1_expout.c
+++ b/
data1/d1_expout.c
@@
-1,8
+1,5
@@
-/* $Id: d1_expout.c,v 1.3 2004-09-28 10:15:03 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
- Index Data Aps
-
-This file is part of the Zebra server.
+/* This file is part of the Zebra server.
+ Copyright (C) 1994-2011 Index Data
Zebra is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Zebra is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
@@
-15,21
+12,26
@@
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
*/
/*
* This module converts data1 tree to Z39.50 Explain records
*/
*/
/*
* This module converts data1 tree to Z39.50 Explain records
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <yaz/log.h>
#include <yaz/proto.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <yaz/log.h>
#include <yaz/proto.h>
+#include <yaz/oid_db.h>
+#include <yaz/snprintf.h>
#include <idzebra/data1.h>
typedef struct {
#include <idzebra/data1.h>
typedef struct {
@@
-47,12
+49,12
@@
static int is_numeric_tag (ExpHandle *eh, data1_node *c)
return 0;
if (!c->u.tag.element)
{
return 0;
if (!c->u.tag.element)
{
- yaz_log(LOG_WARN, "Tag %s is local", c->u.tag.tag);
+ yaz_log(YLOG_WARN, "Tag %s is local", c->u.tag.tag);
return 0;
}
if (c->u.tag.element->tag->which != DATA1T_numeric)
{
return 0;
}
if (c->u.tag.element->tag->which != DATA1T_numeric)
{
- yaz_log(LOG_WARN, "Tag %s is not numeric", c->u.tag.tag);
+ yaz_log(YLOG_WARN, "Tag %s is not numeric", c->u.tag.tag);
return 0;
}
if (eh->select && !c->u.tag.node_selected)
return 0;
}
if (eh->select && !c->u.tag.node_selected)
@@
-69,18
+71,15
@@
static int is_data_tag (ExpHandle *eh, data1_node *c)
return 1;
}
return 1;
}
-static int *f_integer(ExpHandle *eh, data1_node *c)
+static Odr_int *f_integer(ExpHandle *eh, data1_node *c)
{
{
- int *r;
char intbuf[64];
c = c->child;
char intbuf[64];
c = c->child;
- if (!is_data_tag (eh, c) || c->u.data.len > 63)
+ if (!is_data_tag (eh, c) || c->u.data.len >= sizeof(intbuf))
return 0;
return 0;
- r = (int *)odr_malloc(eh->o, sizeof(*r));
sprintf(intbuf, "%.*s", c->u.data.len, c->u.data.data);
sprintf(intbuf, "%.*s", c->u.data.len, c->u.data.data);
- *r = atoi(intbuf);
- return r;
+ return odr_intdup(eh->o, atoi(intbuf));
}
static char *f_string(ExpHandle *eh, data1_node *c)
}
static char *f_string(ExpHandle *eh, data1_node *c)
@@
-113,31
+112,15
@@
static bool_t *f_bool(ExpHandle *eh, data1_node *c)
static Odr_oid *f_oid(ExpHandle *eh, data1_node *c, oid_class oclass)
{
char oidstr[64];
static Odr_oid *f_oid(ExpHandle *eh, data1_node *c, oid_class oclass)
{
char oidstr[64];
- int oid_this[20];
- oid_value value_for_this;
c = c->child;
if (!is_data_tag (eh, c) || c->u.data.len > 63)
return 0;
c = c->child;
if (!is_data_tag (eh, c) || c->u.data.len > 63)
return 0;
- sprintf(oidstr, "%.*s", c->u.data.len, c->u.data.data);
- value_for_this = oid_getvalbyname(oidstr);
- if (value_for_this == VAL_NONE)
- {
- Odr_oid *oid = odr_getoidbystr(eh->o, oidstr);
- assert (oid);
- return oid;
- }
- else
- {
- struct oident ident;
+ yaz_snprintf(oidstr, sizeof(oidstr)-1,
+ "%.*s", c->u.data.len, c->u.data.data);
- ident.oclass = oclass;
- ident.proto = PROTO_Z3950;
- ident.value = value_for_this;
-
- oid_ent_to_oid (&ident, oid_this);
- }
- return odr_oiddup (eh->o, oid_this);
+ return yaz_string_to_oid_odr(yaz_oid_std(),
+ CLASS_GENERAL, oidstr, eh->o);
}
static Z_IntUnit *f_intunit(ExpHandle *eh, data1_node *c)
}
static Z_IntUnit *f_intunit(ExpHandle *eh, data1_node *c)
@@
-201,7
+184,7
@@
Odr_oid **f_oid_seq (ExpHandle *eh, data1_node *n, int *num, oid_class oclass)
++(*num);
if (!*num)
return NULL;
++(*num);
if (!*num)
return NULL;
- res = (int **)odr_malloc (eh->o, sizeof(*res) * (*num));
+ res = (Odr_oid **)odr_malloc (eh->o, sizeof(*res) * (*num));
for (c = n->child, i = 0 ; c; c = c->next)
if (is_numeric_tag (eh, c) == 1000)
res[i++] = f_oid (eh, c, oclass);
for (c = n->child, i = 0 ; c; c = c->next)
if (is_numeric_tag (eh, c) == 1000)
res[i++] = f_oid (eh, c, oclass);
@@
-268,7
+251,7
@@
Z_RpnCapabilities *f_rpnCapabilities (ExpHandle *eh, data1_node *n)
(res->num_operators)++;
}
if (res->num_operators)
(res->num_operators)++;
}
if (res->num_operators)
- res->operators = (int **)
+ res->operators = (Odr_int **)
odr_malloc (eh->o, res->num_operators
* sizeof(*res->operators));
for (n = c->child; n; n = n->next)
odr_malloc (eh->o, res->num_operators
* sizeof(*res->operators));
for (n = c->child; n; n = n->next)
@@
-405,9
+388,8
@@
static Z_AccessInfo *f_accessInfo(ExpHandle *eh, data1_node *n)
return res;
}
return res;
}
-static int *f_recordCount(ExpHandle *eh, data1_node *c, int *which)
+static Odr_int *f_recordCount(ExpHandle *eh, data1_node *c, int *which)
{
{
- int *r= (int *)odr_malloc(eh->o, sizeof(*r));
int *wp = which;
char intbuf[64];
int *wp = which;
char intbuf[64];
@@
-420,11
+402,11
@@
static int *f_recordCount(ExpHandle *eh, data1_node *c, int *which)
*wp = Z_DatabaseInfo_approxNumber;
else
return 0;
*wp = Z_DatabaseInfo_approxNumber;
else
return 0;
- if (!c->child || c->child->which != DATA1N_data)
+ if (!c->child || c->child->which != DATA1N_data ||
+ c->child->u.data.len >= sizeof(intbuf))
return 0;
sprintf(intbuf, "%.*s", c->child->u.data.len, c->child->u.data.data);
return 0;
sprintf(intbuf, "%.*s", c->child->u.data.len, c->child->u.data.data);
- *r = atoi(intbuf);
- return r;
+ return odr_intdup(eh->o, atoi(intbuf));
}
static Z_ContactInfo *f_contactInfo(ExpHandle *eh, data1_node *n)
}
static Z_ContactInfo *f_contactInfo(ExpHandle *eh, data1_node *n)
@@
-1381,7
+1363,7
@@
Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n,
assert(n->which == DATA1N_root);
if (strcmp(n->u.root.type, "explain"))
{
assert(n->which == DATA1N_root);
if (strcmp(n->u.root.type, "explain"))
{
- yaz_log(LOG_WARN, "Attempt to convert a non-Explain record");
+ yaz_log(YLOG_WARN, "Attempt to convert a non-Explain record");
return 0;
}
for (n = n->child; n; n = n->next)
return 0;
}
for (n = n->child; n; n = n->next)
@@
-1415,6
+1397,15
@@
Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n,
return res;
}
}
return res;
}
}
- yaz_log(LOG_WARN, "No category in Explain record");
+ yaz_log(YLOG_WARN, "No category in Explain record");
return 0;
}
return 0;
}
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+