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
Read-only sets uses common no write handler
[idzebra-moved-to-github.git]
/
data1
/
d1_grs.c
diff --git
a/data1/d1_grs.c
b/data1/d1_grs.c
index
db9b5d0
..
a99e0a0
100644
(file)
--- a/
data1/d1_grs.c
+++ b/
data1/d1_grs.c
@@
-1,8
+1,5
@@
-/* $Id: d1_grs.c,v 1.4 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) 2004-2013 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,13
+12,16
@@
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
+
*/
/* converts data1 tree to GRS-1 record */
*/
/* converts data1 tree to GRS-1 record */
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <assert.h>
#include <stdlib.h>
#include <assert.h>
#include <stdlib.h>
@@
-81,10
+81,8
@@
static Z_Variant *make_variant(data1_node *n, int num, ODR o)
assert(p->which == DATA1N_variant);
t = v->triples[num] = (Z_Triple *)odr_malloc(o, sizeof(*t));
t->variantSetId = 0;
assert(p->which == DATA1N_variant);
t = v->triples[num] = (Z_Triple *)odr_malloc(o, sizeof(*t));
t->variantSetId = 0;
- t->zclass = (int *)odr_malloc(o, sizeof(int));
- *t->zclass = p->u.variant.type->zclass->zclass;
- t->type = (int *)odr_malloc(o, sizeof(int));
- *t->type = p->u.variant.type->type;
+ t->zclass = odr_intdup(o, p->u.variant.type->zclass->zclass);
+ t->type = odr_intdup(o, p->u.variant.type->type);
switch (p->u.variant.type->datatype)
{
switch (p->u.variant.type->datatype)
{
@@
-94,7
+92,7
@@
static Z_Variant *make_variant(data1_node *n, int num, ODR o)
odr_strdup(o, p->u.variant.value);
break;
default:
odr_strdup(o, p->u.variant.value);
break;
default:
- yaz_log(LOG_WARN, "Unable to handle value for variant %s",
+ yaz_log(YLOG_WARN, "Unable to handle value for variant %s",
p->u.variant.type->name);
return 0;
}
p->u.variant.type->name);
return 0;
}
@@
-109,7
+107,7
@@
static int traverse_triples(data1_node *n, int level, Z_ElementMetaData *m,
ODR o)
{
data1_node *c;
ODR o)
{
data1_node *c;
-
+
for (c = n->child; c; c = c->next)
if (c->which == DATA1N_data && level)
{
for (c = n->child; c; c = c->next)
if (c->which == DATA1N_data && level)
{
@@
-118,7
+116,7
@@
static int traverse_triples(data1_node *n, int level, Z_ElementMetaData *m,
D1_VARIANTARRAY);
else if (m->num_supportedVariants >= D1_VARIANTARRAY)
{
D1_VARIANTARRAY);
else if (m->num_supportedVariants >= D1_VARIANTARRAY)
{
- yaz_log(LOG_WARN, "Too many variants (D1_VARIANTARRAY==%d)",
+ yaz_log(YLOG_WARN, "Too many variants (D1_VARIANTARRAY==%d)",
D1_VARIANTARRAY);
return -1;
}
D1_VARIANTARRAY);
return -1;
}
@@
-195,8
+193,7
@@
static Z_ElementData *nodetoelementdata(data1_handle dh, data1_node *n,
{
case DATA1I_num:
res->which = Z_ElementData_numeric;
{
case DATA1I_num:
res->which = Z_ElementData_numeric;
- res->u.numeric = (int *)odr_malloc(o, sizeof(int));
- *res->u.numeric = atoi_n (cp, toget);
+ res->u.numeric = odr_intdup(o, atoi_n(cp, toget));
*len += 4;
break;
case DATA1I_text:
*len += 4;
break;
case DATA1I_text:
@@
-218,7
+215,7
@@
static Z_ElementData *nodetoelementdata(data1_handle dh, data1_node *n,
*len += oid_oidlen(res->u.oid) * sizeof(int);
break;
default:
*len += oid_oidlen(res->u.oid) * sizeof(int);
break;
default:
- yaz_log(LOG_WARN, "Can't handle datatype.");
+ yaz_log(YLOG_WARN, "Can't handle datatype.");
return 0;
}
}
return 0;
}
}
@@
-238,7
+235,7
@@
static int is_empty_data (data1_node *n)
|| n->u.data.what == DATA1I_xmltext))
{
int i = n->u.data.len;
|| n->u.data.what == DATA1I_xmltext))
{
int i = n->u.data.len;
-
+
while (i > 0 && d1_isspace(n->u.data.data[i-1]))
i--;
if (i == 0)
while (i > 0 && d1_isspace(n->u.data.data[i-1]))
i--;
if (i == 0)
@@
-294,26
+291,24
@@
static Z_TaggedElement *nodetotaggedelement(data1_handle dh, data1_node *n,
}
else
{
}
else
{
- yaz_log(LOG_WARN, "Bad data.");
+ yaz_log(YLOG_WARN, "Bad data.");
return 0;
}
return 0;
}
- res->tagType = (int *)odr_malloc(o, sizeof(int));
- *res->tagType = (tag && tag->tagset) ? tag->tagset->type : 3;
+ res->tagType = odr_intdup(o, (tag && tag->tagset) ? tag->tagset->type : 3);
res->tagValue = (Z_StringOrNumeric *)odr_malloc(o, sizeof(Z_StringOrNumeric));
if (tag && tag->which == DATA1T_numeric)
{
res->tagValue->which = Z_StringOrNumeric_numeric;
res->tagValue = (Z_StringOrNumeric *)odr_malloc(o, sizeof(Z_StringOrNumeric));
if (tag && tag->which == DATA1T_numeric)
{
res->tagValue->which = Z_StringOrNumeric_numeric;
- res->tagValue->u.numeric = (int *)odr_malloc(o, sizeof(int));
- *res->tagValue->u.numeric = tag->value.numeric;
+ res->tagValue->u.numeric = odr_intdup(o, tag->value.numeric);
}
else
{
char *tagstr;
}
else
{
char *tagstr;
- if (n->which == DATA1N_tag)
+ if (n->which == DATA1N_tag)
tagstr = n->u.tag.tag; /* tag at node */
tagstr = n->u.tag.tag; /* tag at node */
- else if (tag)
+ else if (tag)
tagstr = tag->value.string; /* no take from well-known */
else
return 0;
tagstr = tag->value.string; /* no take from well-known */
else
return 0;
@@
-392,7
+387,7
@@
Z_GenericRecord *data1_nodetogr(data1_handle dh, data1_node *n,
data1_gettagbyname (dh, n->root->u.root.absyn->tagset,
"wellKnown")))
{
data1_gettagbyname (dh, n->root->u.root.absyn->tagset,
"wellKnown")))
{
- yaz_log(LOG_WARN, "Unable to locate tag for 'wellKnown'");
+ yaz_log(YLOG_WARN, "Unable to locate tag for 'wellKnown'");
wellknown_tag = odr_malloc(o, sizeof(*wellknown_tag));
wellknown_tag->which = DATA1T_numeric;
wellknown_tag->value.numeric = 19;
wellknown_tag = odr_malloc(o, sizeof(*wellknown_tag));
wellknown_tag->which = DATA1T_numeric;
wellknown_tag->value.numeric = 19;
@@
-403,3
+398,12
@@
Z_GenericRecord *data1_nodetogr(data1_handle dh, data1_node *n,
}
return data1_nodetogr_r(dh, n, select, o, len, wellknown_tag);
}
}
return data1_nodetogr_r(dh, n, select, o, len, wellknown_tag);
}
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+