projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix a few Doxygen warnings
[yaz-moved-to-github.git]
/
src
/
solrtransform.c
diff --git
a/src/solrtransform.c
b/src/solrtransform.c
index
1b323f4
..
29278ba
100644
(file)
--- a/
src/solrtransform.c
+++ b/
src/solrtransform.c
@@
-1,5
+1,5
@@
/* This file is part of the YAZ toolkit.
/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2010 Index Data
+ * Copyright (C) 1995-2013 Index Data
* See the file LICENSE for details.
*/
/**
* See the file LICENSE for details.
*/
/**
@@
-13,7
+13,6
@@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
#include <yaz/rpn2solr.h>
#include <yaz/xmalloc.h>
#include <yaz/diagsrw.h>
#include <yaz/rpn2solr.h>
#include <yaz/xmalloc.h>
#include <yaz/diagsrw.h>
@@
-42,7
+41,7
@@
struct solr_transform_t_ {
};
};
-/* TODO Utility functions, evt. split out int separate file */
+/* TODO Utility functions, split out into separate file */
int solr_strcmp(const char *s1, const char *s2) {
return cql_strcmp(s1, s2);
}
int solr_strcmp(const char *s1, const char *s2) {
return cql_strcmp(s1, s2);
}
@@
-71,7
+70,7
@@
void solr_buf_write_handler (const char *b, void *client_data)
}
}
-/* Utillity functions end */
+/* Utility functions end */
solr_transform_t solr_transform_create(void)
{
solr_transform_t solr_transform_create(void)
{
@@
-94,7
+93,7
@@
static int solr_transform_parse_tok_line(solr_transform_t ct,
int ret = 0; /* 0=OK, != 0 FAIL */
int t;
t = yaz_tok_move(tp);
int ret = 0; /* 0=OK, != 0 FAIL */
int t;
t = yaz_tok_move(tp);
-
+
while (t == YAZ_TOK_STRING && ae_num < 20)
{
WRBUF type_str = wrbuf_alloc();
while (t == YAZ_TOK_STRING && ae_num < 20)
{
WRBUF type_str = wrbuf_alloc();
@@
-102,7
+101,7
@@
static int solr_transform_parse_tok_line(solr_transform_t ct,
Z_AttributeElement *elem = 0;
const char *value_str = 0;
/* attset type=value OR type=value */
Z_AttributeElement *elem = 0;
const char *value_str = 0;
/* attset type=value OR type=value */
-
+
elem = (Z_AttributeElement *) nmem_malloc(ct->nmem, sizeof(*elem));
elem->attributeSet = 0;
ae[ae_num] = elem;
elem = (Z_AttributeElement *) nmem_malloc(ct->nmem, sizeof(*elem));
elem->attributeSet = 0;
ae[ae_num] = elem;
@@
-113,19
+112,19
@@
static int solr_transform_parse_tok_line(solr_transform_t ct,
{
wrbuf_destroy(type_str);
if (set_str)
{
wrbuf_destroy(type_str);
if (set_str)
- wrbuf_destroy(set_str);
+ wrbuf_destroy(set_str);
break;
}
break;
}
- if (t == YAZ_TOK_STRING)
- {
+ if (t == YAZ_TOK_STRING)
+ {
wrbuf_puts(ct->w, " ");
wrbuf_puts(ct->w, yaz_tok_parse_string(tp));
set_str = type_str;
wrbuf_puts(ct->w, " ");
wrbuf_puts(ct->w, yaz_tok_parse_string(tp));
set_str = type_str;
-
+
elem->attributeSet =
yaz_string_to_oid_nmem(yaz_oid_std(), CLASS_ATTSET,
wrbuf_cstr(set_str), ct->nmem);
elem->attributeSet =
yaz_string_to_oid_nmem(yaz_oid_std(), CLASS_ATTSET,
wrbuf_cstr(set_str), ct->nmem);
-
+
type_str = wrbuf_alloc();
wrbuf_puts(type_str, yaz_tok_parse_string(tp));
t = yaz_tok_move(tp);
type_str = wrbuf_alloc();
wrbuf_puts(type_str, yaz_tok_parse_string(tp));
t = yaz_tok_move(tp);
@@
-136,7
+135,7
@@
static int solr_transform_parse_tok_line(solr_transform_t ct,
{
wrbuf_destroy(type_str);
if (set_str)
{
wrbuf_destroy(type_str);
if (set_str)
- wrbuf_destroy(set_str);
+ wrbuf_destroy(set_str);
yaz_log(YLOG_WARN, "Expected numeric attribute type");
ret = -1;
break;
yaz_log(YLOG_WARN, "Expected numeric attribute type");
ret = -1;
break;
@@
-144,8
+143,8
@@
static int solr_transform_parse_tok_line(solr_transform_t ct,
wrbuf_destroy(type_str);
if (set_str)
wrbuf_destroy(type_str);
if (set_str)
- wrbuf_destroy(set_str);
-
+ wrbuf_destroy(set_str);
+
if (t != '=')
{
yaz_log(YLOG_WARN, "Expected = after after attribute type");
if (t != '=')
{
yaz_log(YLOG_WARN, "Expected = after after attribute type");
@@
-160,7
+159,7
@@
static int solr_transform_parse_tok_line(solr_transform_t ct,
break;
}
value_str = yaz_tok_parse_string(tp);
break;
}
value_str = yaz_tok_parse_string(tp);
- if (isdigit(*value_str))
+ if (yaz_isdigit(*value_str))
{
elem->which = Z_AttributeValue_numeric;
elem->value.numeric =
{
elem->which = Z_AttributeValue_numeric;
elem->value.numeric =
@@
-205,7
+204,7
@@
static int solr_transform_parse_tok_line(solr_transform_t ct,
(*pp)->attr_list.attributes = (Z_AttributeElement **)
nmem_malloc(ct->nmem,
ae_num * sizeof(Z_AttributeElement *));
(*pp)->attr_list.attributes = (Z_AttributeElement **)
nmem_malloc(ct->nmem,
ae_num * sizeof(Z_AttributeElement *));
- memcpy((*pp)->attr_list.attributes, ae,
+ memcpy((*pp)->attr_list.attributes, ae,
ae_num * sizeof(Z_AttributeElement *));
}
(*pp)->next = 0;
ae_num * sizeof(Z_AttributeElement *));
}
(*pp)->next = 0;
@@
-233,7
+232,7
@@
int solr_transform_define_pattern(solr_transform_t ct, const char *pattern,
yaz_tok_parse_destroy(tp);
return r;
}
yaz_tok_parse_destroy(tp);
return r;
}
-
+
solr_transform_t solr_transform_open_FILE(FILE *f)
{
solr_transform_t ct = solr_transform_create();
solr_transform_t solr_transform_open_FILE(FILE *f)
{
solr_transform_t ct = solr_transform_create();
@@
-332,7
+331,7
@@
static int compare_attr(Z_AttributeElement *a, Z_AttributeElement *b)
z_AttributeElement(odr_a, &a, 0, 0);
z_AttributeElement(odr_b, &b, 0, 0);
z_AttributeElement(odr_a, &a, 0, 0);
z_AttributeElement(odr_b, &b, 0, 0);
-
+
buf_a = odr_getbuf(odr_a, &len_a, 0);
buf_b = odr_getbuf(odr_b, &len_b, 0);
buf_a = odr_getbuf(odr_a, &len_a, 0);
buf_b = odr_getbuf(odr_b, &len_b, 0);
@@
-371,7
+370,7
@@
const char *solr_lookup_reverse(solr_transform_t ct,
}
if (j == attributes->num_attributes)
break; /* i was not found at all.. try next pattern */
}
if (j == attributes->num_attributes)
break; /* i was not found at all.. try next pattern */
-
+
}
if (i == e->attr_list.num_attributes)
return e->pattern + clen;
}
if (i == e->attr_list.num_attributes)
return e->pattern + clen;
@@
-379,7
+378,7
@@
const char *solr_lookup_reverse(solr_transform_t ct,
}
return 0;
}
}
return 0;
}
-
+
static const char *solr_lookup_property(solr_transform_t ct,
const char *pat1, const char *pat2,
const char *pat3)
static const char *solr_lookup_property(solr_transform_t ct,
const char *pat1, const char *pat2,
const char *pat3)
@@
-397,7
+396,7
@@
static const char *solr_lookup_property(solr_transform_t ct,
sprintf(pattern, "%.39s", pat1);
else
return 0;
sprintf(pattern, "%.39s", pat1);
else
return 0;
-
+
for (e = ct->entry; e; e = e->next)
{
if (!solr_strcmp(e->pattern, pattern))
for (e = ct->entry; e; e = e->next)
{
if (!solr_strcmp(e->pattern, pattern))
@@
-415,11
+414,11
@@
int solr_pr_attr_uri(solr_transform_t ct, const char *category,
const char *res = 0;
const char *eval = val ? val : default_val;
const char *prefix = 0;
const char *res = 0;
const char *eval = val ? val : default_val;
const char *prefix = 0;
-
+
if (uri)
{
struct solr_prop_entry *e;
if (uri)
{
struct solr_prop_entry *e;
-
+
for (e = ct->entry; e; e = e->next)
if (!memcmp(e->pattern, "set.", 4) && e->value &&
!strcmp(e->value, uri))
for (e = ct->entry; e; e = e->next)
if (!memcmp(e->pattern, "set.", 4) && e->value &&
!strcmp(e->value, uri))
@@
-523,8
+522,7
@@
static int solr_pr_prox(solr_transform_t ct, struct solr_node *mods,
void *client_data)
{
int exclusion = 0;
void *client_data)
{
int exclusion = 0;
- int distance; /* to be filled in later depending on unit */
- int distance_defined = 0;
+ int distance = -1;
int ordered = 0;
int proxrel = 2; /* less than or equal */
int unit = 2; /* word */
int ordered = 0;
int proxrel = 2; /* less than or equal */
int unit = 2; /* word */
@@
-537,26
+535,25
@@
static int solr_pr_prox(solr_transform_t ct, struct solr_node *mods,
if (!strcmp(name, "distance")) {
distance = strtol(term, (char**) 0, 0);
if (!strcmp(name, "distance")) {
distance = strtol(term, (char**) 0, 0);
- distance_defined = 1;
if (!strcmp(relation, "="))
proxrel = 3;
else if (!strcmp(relation, ">"))
proxrel = 5;
else if (!strcmp(relation, "<"))
proxrel = 1;
if (!strcmp(relation, "="))
proxrel = 3;
else if (!strcmp(relation, ">"))
proxrel = 5;
else if (!strcmp(relation, "<"))
proxrel = 1;
- else if (!strcmp(relation, ">="))
+ else if (!strcmp(relation, ">="))
proxrel = 4;
else if (!strcmp(relation, "<="))
proxrel = 2;
else if (!strcmp(relation, "<>"))
proxrel = 6;
proxrel = 4;
else if (!strcmp(relation, "<="))
proxrel = 2;
else if (!strcmp(relation, "<>"))
proxrel = 6;
- else
+ else
{
ct->error = YAZ_SRW_UNSUPP_PROX_RELATION;
ct->addinfo = xstrdup(relation);
return 0;
}
{
ct->error = YAZ_SRW_UNSUPP_PROX_RELATION;
ct->addinfo = xstrdup(relation);
return 0;
}
- }
+ }
else if (!strcmp(name, "ordered"))
ordered = 1;
else if (!strcmp(name, "unordered"))
else if (!strcmp(name, "ordered"))
ordered = 1;
else if (!strcmp(name, "unordered"))
@@
-571,14
+568,14
@@
static int solr_pr_prox(solr_transform_t ct, struct solr_node *mods,
unit = 4;
else if (!strcmp(term, "element"))
unit = 8;
unit = 4;
else if (!strcmp(term, "element"))
unit = 8;
- else
+ else
{
ct->error = YAZ_SRW_UNSUPP_PROX_UNIT;
ct->addinfo = xstrdup(term);
return 0;
}
{
ct->error = YAZ_SRW_UNSUPP_PROX_UNIT;
ct->addinfo = xstrdup(term);
return 0;
}
- }
- else
+ }
+ else
{
ct->error = YAZ_SRW_UNSUPP_BOOLEAN_MODIFIER;
ct->addinfo = xstrdup(name);
{
ct->error = YAZ_SRW_UNSUPP_BOOLEAN_MODIFIER;
ct->addinfo = xstrdup(name);
@@
-587,7
+584,7
@@
static int solr_pr_prox(solr_transform_t ct, struct solr_node *mods,
mods = mods->u.st.modifiers;
}
mods = mods->u.st.modifiers;
}
- if (!distance_defined)
+ if (distance == -1)
distance = (unit == 2) ? 1 : 0;
solr_pr_int(exclusion, pr, client_data);
distance = (unit == 2) ? 1 : 0;
solr_pr_int(exclusion, pr, client_data);
@@
-685,8
+682,8
@@
static void emit_term(solr_transform_t ct,
* there's no mapping for it, that's fine: we just use a
* general pattern-matching attribute.
*/
* there's no mapping for it, that's fine: we just use a
* general pattern-matching attribute.
*/
- if (first_wc == term && second_wc == term + length-1
- && *first_wc == '*' && *second_wc == '*'
+ if (first_wc == term && second_wc == term + length-1
+ && *first_wc == '*' && *second_wc == '*'
&& solr_pr_attr(ct, "truncation", "both", 0, pr, client_data, 0))
{
term++;
&& solr_pr_attr(ct, "truncation", "both", 0, pr, client_data, 0))
{
term++;
@@
-794,7
+791,7
@@
static void emit_terms(solr_transform_t ct,
(*pr)("@", client_data);
(*pr)(op, client_data);
(*pr)(" ", client_data);
(*pr)("@", client_data);
(*pr)(op, client_data);
(*pr)(" ", client_data);
- }
+ }
emit_term(ct, cn, ne->u.st.term, strlen(ne->u.st.term),
pr, client_data);
}
emit_term(ct, cn, ne->u.st.term, strlen(ne->u.st.term),
pr, client_data);
}
@@
-884,11
+881,11
@@
void solr_transform_r(solr_transform_t ct,
(*pr)(cn->u.boolean.value, client_data);
(*pr)(" ", client_data);
mods = cn->u.boolean.modifiers;
(*pr)(cn->u.boolean.value, client_data);
(*pr)(" ", client_data);
mods = cn->u.boolean.modifiers;
- if (!strcmp(cn->u.boolean.value, "prox"))
+ if (!strcmp(cn->u.boolean.value, "prox"))
{
if (!solr_pr_prox(ct, mods, pr, client_data))
return;
{
if (!solr_pr_prox(ct, mods, pr, client_data))
return;
- }
+ }
else if (mods)
{
/* Boolean modifiers other than on proximity not supported */
else if (mods)
{
/* Boolean modifiers other than on proximity not supported */