-/* $Id: zrpn.c,v 1.126 2002-12-16 22:59:34 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: zrpn.c,v 1.129 2003-02-27 11:29:13 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
This file is part of the Zebra server.
#include <ctype.h>
#include "index.h"
+#include <zebra_xpath.h>
#include <charmap.h>
#include <rstemp.h>
int reg_type;
};
+typedef struct {
+ int type;
+ int major;
+ int minor;
+ Z_AttributesPlusTerm *zapt;
+} AttrType;
+
+
static const char **rpn_char_map_handler (void *vp, const char **from, int len)
{
struct rpn_char_map_info *p = (struct rpn_char_map_info *) vp;
dict_grep_cmap (reg->dict, map_info, rpn_char_map_handler);
}
-typedef struct {
- int type;
- int major;
- int minor;
- Z_AttributesPlusTerm *zapt;
-} AttrType;
-
static int attr_find_ex (AttrType *src, oid_value *attributeSetP,
const char **string_value)
{
int i = 0;
int j = 0;
- if (!term_pre (zebra_maps, reg_type, src, "#!", "#!"))
+ if (!term_pre (zebra_maps, reg_type, src, "?*#", "?*#"))
return 0;
s0 = *src;
while (*s0)
{
- if (*s0 == '#')
+ if (*s0 == '?')
+ {
+ dst_term[j++] = *s0++;
+ if (*s0 >= '0' && *s0 <= '9')
+ {
+ int limit = 0;
+ while (*s0 >= '0' && *s0 <= '9')
+ {
+ limit = limit * 10 + (*s0 - '0');
+ dst_term[j++] = *s0++;
+ }
+ if (limit > 20)
+ limit = 20;
+ while (--limit >= 0)
+ {
+ dst[i++] = '.';
+ dst[i++] = '?';
+ }
+ }
+ else
+ {
+ dst[i++] = '.';
+ dst[i++] = '*';
+ }
+ }
+ else if (*s0 == '*')
{
dst[i++] = '.';
dst[i++] = '*';
dst_term[j++] = *s0++;
}
- else if (*s0 == '!')
+ else if (*s0 == '#')
{
dst[i++] = '.';
dst_term[j++] = *s0++;
{
/* set was found, but value wasn't defined */
char val_str[32];
- sprintf (val_str, "%d (1)", use_value);
+ sprintf (val_str, "%d", use_value);
zh->errCode = 114;
zh->errString = nmem_strdup (stream, val_str);
}
if (!prefix_len)
{
char val_str[32];
- sprintf (val_str, "%d (2)", use_value);
+ sprintf (val_str, "%d", use_value);
zh->errCode = 114;
zh->errString = nmem_strdup (stream, val_str);
return -1;
oid_value attributeSet, struct grep_info *grep_info,
int reg_type, int complete_flag,
int num_bases, char **basenames,
- char *term_dst, int xpath_use)
+ char *term_dst, int xpath_use, NMEM stream)
{
char term_dict[2*IT_MAX_WORD+2];
int r, base_no;
logf (LOG_DEBUG, "att_getentbyatt fail. set=%d use=%d r=%d",
curAttributeSet, use_value, r);
if (r == -1)
+ {
+ char val_str[32];
+ sprintf (val_str, "%d", use_value);
+ zh->errString = nmem_strdup (stream, val_str);
zh->errCode = 114;
+ }
else
zh->errCode = 121;
return -1;
}
if (!prefix_len)
{
+ char val_str[32];
+ sprintf (val_str, "%d", use_value);
zh->errCode = 114;
+ zh->errString = nmem_strdup (stream, val_str);
return -1;
}
term_dict[prefix_len++] = ')';
grep_info.isam_p_indx = 0;
r = numeric_term (zh, zapt, &termp, attributeSet, &grep_info,
reg_type, complete_flag, num_bases, basenames,
- term_dst, xpath_use);
+ term_dst, xpath_use,
+ stream);
if (r < 1)
break;
logf (LOG_DEBUG, "term: %s", term_dst);
return rset_create (rset_kind_null, &parms);
}
+/* pop - moved to xpath.c */
+#if 0
+
struct xpath_predicate {
int which;
union {
struct xpath_predicate *predicate;
};
+#endif
+
static int parse_xpath(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
oid_value attributeSet,
struct xpath_location_step *xpath, NMEM mem)
oid_value curAttributeSet = attributeSet;
AttrType use;
const char *use_string = 0;
- const char *cp;
int no = 0;
attr_init (&use, zapt, 1);
if (!use_string || *use_string != '/')
return -1;
- cp = use_string;
- while (*cp)
- {
- int i = 0;
- while (*cp && !strchr("/[",*cp))
- {
- i++;
- cp++;
- }
- xpath[no].predicate = 0;
- xpath[no].part = nmem_malloc (mem, i+1);
- memcpy (xpath[no].part, cp - i, i);
- xpath[no].part[i] = 0;
- if (*cp == '[')
- {
- struct xpath_predicate *p = xpath[no].predicate =
- nmem_malloc (mem, sizeof(struct xpath_predicate));
-
- p->which = XPATH_PREDICATE_RELATION;
- cp++;
- while (*cp == ' ')
- cp++;
-
- for (i = 0; *cp && !strchr("><=] ", *cp); i++)
- cp++;
- p->u.relation.name = nmem_malloc (mem, i+1);
- memcpy (p->u.relation.name, cp - i, i);
- p->u.relation.name[i] = 0;
- while (*cp == ' ')
- cp++;
- if (*cp != ']')
- {
- for (i = 0; *cp && strchr(">=<!", *cp); i++)
- cp++;
-
- p->u.relation.op = nmem_malloc (mem, i+1);
- if (i)
- memcpy (p->u.relation.op, cp - i, i);
- p->u.relation.op[i] = 0;
-
- while (*cp == ' ')
- cp++;
-
- if (strchr("\"'", *cp))
- {
- cp++;
- for (i = 0; *cp && !strchr("\"'", *cp); i++)
- cp++;
-
- p->u.relation.value = nmem_malloc (mem, i+1);
- if (i)
- memcpy (p->u.relation.value, cp - i, i);
- p->u.relation.value[i] = 0;
- yaz_log (LOG_LOG, "value=%s", p->u.relation.value);
-
- cp++;
- }
- else
- {
- for (i = 0; *cp && !strchr(" ]", *cp); i++)
- cp++;
- p->u.relation.value = nmem_malloc (mem, i+1);
- if (i)
- memcpy (p->u.relation.value, cp - i, i);
- p->u.relation.value[i] = 0;
- }
- while (*cp == ' ')
- cp++;
- }
- if (*cp == ']')
- cp++;
- } /* end of ] predicate */
- no++;
- if (*cp != '/')
- break;
- cp++;
- }
- return no;
+ return (parse_xpath_str(use_string, xpath, mem));
}
-
+
+
static RSET xpath_trunc(ZebraHandle zh, NMEM stream,
int reg_type, const char *term, int use,
logf (LOG_DEBUG, "att_getentbyatt fail. set=%d use=%d",
attributeset, use_value);
if (r == -1)
- zh->errCode = 114;
+ {
+ char val_str[32];
+ sprintf (val_str, "%d", use_value);
+ zh->errCode = 114;
+ zh->errString = odr_strdup (stream, val_str);
+ }
else
zh->errCode = 121;
*num_entries = 0;