Added support for definition of CCL operators in field spec file.
Possible compatibility problems with earlier versions marked with '*'.
+CCL operator names may be set in field definition files (CCL_bibset).
+See ccl/bib1 for an example.
+
Fixes in ASN.1 compiler for C++ compatibility.
-* Changed member names "and", "or" and "and_not" in struct Z_Operator
-to "op_and", "op_or" and "op_and_not" to avoid conflict with C++.
+* Renamed members "and" and "or" in struct Z_Operator to "op_and"
+and "op_or" to avoid conflict with C++.
Fixed problem with GNU readline detection on Redhat 7.0.
-# $Id: bib1,v 1.5 2000-12-29 11:12:12 adam Exp $
+# $Id: bib1,v 1.6 2001-03-07 13:24:40 adam Exp $
# CCL qualifiers and their mappings
#
# Each line takes the form:
# This rule is for CCL tokens where no fields are specified
term s=pw t=l,r s=al
# Common short-hand access points.
-au u=1 s=pw t=l,r
-ti u=4 s=pw t=l,r
+au u=1 s=pw t=l,r # author
+ti u=4 s=pw t=l,r # title
isbn u=7
issn u=8
cc u=20
exp:category exp1,1=1
+# These special directives defines names of keywords for parser
+@and og * # either 'or' or *
+@or eller + # either 'eller' or +
+@not ikke - # and so on..
+@set s set
+@case 0 # case insenstive (1 for case sensitive)
* Europagate, 1995
*
* $Log: cclfind.c,v $
- * Revision 1.21 2001-02-21 13:46:53 adam
+ * Revision 1.22 2001-03-07 13:24:40 adam
+ * Member and_not in Z_Operator is kept for backwards compatibility.
+ * Added support for definition of CCL operators in field spec file.
+ *
+ * Revision 1.21 2001/02/21 13:46:53 adam
* C++ fixes.
*
* Revision 1.20 2000/11/16 13:03:12 adam
{
struct ccl_rpn_node *p;
+
+
cclp->look_token = list;
p = find_spec (cclp, NULL);
if (p && KIND != CCL_TOK_EOL)
* Europagate, 1995
*
* $Log: cclqfile.c,v $
- * Revision 1.8 2001-02-21 13:46:53 adam
+ * Revision 1.9 2001-03-07 13:24:40 adam
+ * Member and_not in Z_Operator is kept for backwards compatibility.
+ * Added support for definition of CCL operators in field spec file.
+ *
+ * Revision 1.8 2001/02/21 13:46:53 adam
* C++ fixes.
*
* Revision 1.7 2001/01/24 11:55:31 adam
#include <yaz/ccl.h>
-void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name)
+void ccl_qual_field (CCL_bibset bibset, const char *cp, const char *qual_name)
{
char qual_spec[128];
int no_scan;
ccl_qual_add_set (bibset, qual_name, pair_no, pair, attsets);
}
+void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name)
+{
+ if (*qual_name == '@')
+ ccl_qual_add_special(bibset, qual_name+1, cp);
+ else
+ ccl_qual_field(bibset, cp, qual_name);
+}
+
/*
* ccl_qual_file: Read bibset definition from file.
* bibset: Bibset
void ccl_qual_file (CCL_bibset bibset, FILE *inf)
{
char line[256];
- char *cp;
+ char *cp, *cp1;
char qual_name[128];
int no_scan;
if (sscanf (cp, "%s%n", qual_name, &no_scan) != 1)
continue; /* also ignore empty lines */
cp += no_scan;
+ cp1 = strchr(cp, '#');
+ if (cp1)
+ *cp1 = '\0';
ccl_qual_fitem (bibset, cp, qual_name);
}
}
* Europagate, 1995
*
* $Log: cclqual.c,v $
- * Revision 1.14 2000-11-16 09:58:02 adam
+ * Revision 1.15 2001-03-07 13:24:40 adam
+ * Member and_not in Z_Operator is kept for backwards compatibility.
+ * Added support for definition of CCL operators in field spec file.
+ *
+ * Revision 1.14 2000/11/16 09:58:02 adam
* Implemented local AttributeSet setting for CCL field maps.
*
* Revision 1.13 2000/01/31 13:15:21 adam
/* Definition of CCL_bibset pointer */
struct ccl_qualifiers {
struct ccl_qualifier *list;
+ struct ccl_qualifier_special *special;
+};
+
+
+/* CCL Qualifier special */
+struct ccl_qualifier_special {
+ char *name;
+ char *value;
+ struct ccl_qualifier_special *next;
};
+void ccl_qual_add_special (CCL_bibset bibset, const char *n, const char *v)
+{
+ struct ccl_qualifier_special *p;
+ const char *pe;
+
+ for (p = bibset->special; p && strcmp(p->name, n); p = p->next)
+ ;
+ if (p)
+ free (p->value);
+ else
+ {
+ p = (struct ccl_qualifier_special *) malloc (sizeof(*p));
+ p->name = ccl_strdup (n);
+ p->value = 0;
+ p->next = bibset->special;
+ bibset->special = p;
+ }
+ while (strchr(" \t", *v))
+ ++v;
+ for (pe = v + strlen(v); pe != v; --pe)
+ if (!strchr(" \n\r\t", pe[-1]))
+ break;
+ p->value = (char*) malloc (pe - v + 1);
+ if (pe - v)
+ memcpy (p->value, v, pe - v);
+ p->value[pe - v] = '\0';
+}
+
+
/*
* ccl_qual_add: Add qualifier to Bibset. If qualifier already
* exists, then attributes are appendend to old
CCL_bibset b = (CCL_bibset)malloc (sizeof(*b));
ccl_assert (b);
b->list = NULL;
+ b->special = NULL;
return b;
}
void ccl_qual_rm (CCL_bibset *b)
{
struct ccl_qualifier *q, *q1;
+ struct ccl_qualifier_special *sp, *sp1;
if (!*b)
return;
free (q->name);
free (q);
}
+ for (sp = (*b)->special; sp; sp = sp1)
+ {
+ sp1 = sp->next;
+ free (sp->name);
+ free (sp->value);
+ free (sp);
+ }
free (*b);
*b = NULL;
}
return NULL;
}
+const char *ccl_qual_search_special (CCL_bibset b,
+ const char *name)
+{
+ struct ccl_qualifier_special *q;
+ if (!b)
+ return 0;
+ for (q = b->special; q && strcmp(q->name, name); q = q->next)
+ ;
+ if (q)
+ return q->value;
+ return 0;
+}
* Europagate, 1995
*
* $Log: ccltoken.c,v $
- * Revision 1.15 2000-05-01 09:36:50 adam
+ * Revision 1.16 2001-03-07 13:24:40 adam
+ * Member and_not in Z_Operator is kept for backwards compatibility.
+ * Added support for definition of CCL operators in field spec file.
+ *
+ * Revision 1.15 2000/05/01 09:36:50 adam
* Range operator only treated in ordered ranges so that minus (-) can be
* used for, say, the and-not operator.
*
{
const char *cp1 = kw;
const char *cp2;
+ const char *aliases;
+ int case_sensitive = cclp->ccl_case_sensitive;
+
+ aliases = ccl_qual_search_special(cclp->bibset, "case");
+ if (aliases)
+ case_sensitive = atoi(aliases);
if (!kw)
return 0;
while ((cp2 = strchr (cp1, ' ')))
{
if (token->len == (size_t) (cp2-cp1))
{
- if (cclp->ccl_case_sensitive)
+ if (case_sensitive)
{
if (!memcmp (cp1, token->name, token->len))
return 1;
}
cp1 = cp2+1;
}
- if (cclp->ccl_case_sensitive)
+ if (case_sensitive)
return token->len == strlen(cp1)
&& !memcmp (cp1, token->name, token->len);
return token->len == strlen(cp1) &&
*/
struct ccl_token *ccl_parser_tokenize (CCL_parser cclp, const char *command)
{
+ const char *aliases;
const char *cp = command;
struct ccl_token *first = NULL;
struct ccl_token *last = NULL;
cp++;
++ last->len;
}
- if (token_cmp (cclp, cclp->ccl_token_and, last))
+ last->kind = CCL_TOK_TERM;
+
+ aliases = ccl_qual_search_special(cclp->bibset, "and");
+ if (!aliases)
+ aliases = cclp->ccl_token_and;
+ if (token_cmp (cclp, aliases, last))
last->kind = CCL_TOK_AND;
- else if (token_cmp (cclp, cclp->ccl_token_or, last))
+
+ aliases = ccl_qual_search_special(cclp->bibset, "or");
+ if (!aliases)
+ aliases = cclp->ccl_token_or;
+ if (token_cmp (cclp, aliases, last))
last->kind = CCL_TOK_OR;
- else if (token_cmp (cclp, cclp->ccl_token_not, last))
+
+ aliases = ccl_qual_search_special(cclp->bibset, "not");
+ if (!aliases)
+ aliases = cclp->ccl_token_not;
+ if (token_cmp (cclp, aliases, last))
last->kind = CCL_TOK_NOT;
- else if (token_cmp (cclp, cclp->ccl_token_set, last))
+
+ aliases = ccl_qual_search_special(cclp->bibset, "set");
+ if (!aliases)
+ aliases = cclp->ccl_token_set;
+
+ if (token_cmp (cclp, aliases, last))
last->kind = CCL_TOK_SET;
- else
- last->kind = CCL_TOK_TERM;
}
}
return first;
}
}
-static char *ccl_strdup (const char *str)
+char *ccl_strdup (const char *str)
{
int len = strlen(str);
char *p = (char*) malloc (len+1);
void ccl_parser_set_op_and (CCL_parser p, const char *op)
{
if (p && op)
+ {
+ if (p->ccl_token_and)
+ free (p->ccl_token_and);
p->ccl_token_and = ccl_strdup (op);
+ }
}
void ccl_parser_set_op_or (CCL_parser p, const char *op)
{
if (p && op)
+ {
+ if (p->ccl_token_or)
+ free (p->ccl_token_or);
p->ccl_token_or = ccl_strdup (op);
+ }
}
void ccl_parser_set_op_not (CCL_parser p, const char *op)
{
if (p && op)
+ {
+ if (p->ccl_token_not)
+ free (p->ccl_token_not);
p->ccl_token_not = ccl_strdup (op);
+ }
}
void ccl_parser_set_op_set (CCL_parser p, const char *op)
{
if (p && op)
+ {
+ if (p->ccl_token_set)
+ free (p->ccl_token_set);
p->ccl_token_set = ccl_strdup (op);
+ }
}
void ccl_parser_set_case (CCL_parser p, int case_sensitivity_flag)
* CCL - header file
*
* $Log: ccl.h,v $
- * Revision 1.8 2000-11-16 09:58:02 adam
+ * Revision 1.9 2001-03-07 13:24:40 adam
+ * Member and_not in Z_Operator is kept for backwards compatibility.
+ * Added support for definition of CCL operators in field spec file.
+ *
+ * Revision 1.8 2000/11/16 09:58:02 adam
* Implemented local AttributeSet setting for CCL field maps.
*
* Revision 1.7 2000/11/01 14:47:00 adam
/* Destroy CCL parser */
YAZ_EXPORT void ccl_parser_destroy (CCL_parser p);
+YAZ_EXPORT char *ccl_strdup (const char *str);
+
+YAZ_EXPORT const char *ccl_qual_search_special (CCL_bibset b,
+ const char *name);
#ifndef ccl_assert
#define ccl_assert(x) ;
# YC Sample Config File for Z39.50
-# $Id: z.tcl,v 1.4 2001-02-21 13:46:54 adam Exp $
+# $Id: z.tcl,v 1.5 2001-03-07 13:24:40 adam Exp $
# ----------------------------------------------------------
# Prefix Specifications
#
set map($m,PDU) APDU
set membermap($m,Operator,and) {Operator_and op_and}
set membermap($m,Operator,or) {Operator_or op_or}
-set membermap($m,Operator,and-not) {Operator_and_not op_and_not}
+#set membermap($m,Operator,and-not) {Operator_and_not op_and_not}
set map($m,AttributeElement_complex) ComplexAttribute
set map($m,DeleteSetStatus) DeleteStatus
set membermap($m,ProximityOperator,private) {ProximityOperator_private zprivate}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: pquery.c,v $
- * Revision 1.5 2001-02-21 13:46:54 adam
+ * Revision 1.6 2001-03-07 13:24:40 adam
+ * Member and_not in Z_Operator is kept for backwards compatibility.
+ * Added support for definition of CCL operators in field spec file.
+ *
+ * Revision 1.5 2001/02/21 13:46:54 adam
* C++ fixes.
*
* Revision 1.4 1999/12/21 16:25:20 adam
{
case 'a':
zo->which = Z_Operator_and;
- zo->u.op_and = odr_nullval();
+ zo->u.and_not = odr_nullval();
break;
case 'o':
zo->which = Z_Operator_or;
- zo->u.op_or = odr_nullval();
+ zo->u.and_not = odr_nullval();
break;
case 'n':
zo->which = Z_Operator_and_not;
- zo->u.op_and_not = odr_nullval();
+ zo->u.and_not = odr_nullval();
break;
case 'p':
zo->which = Z_Operator_prox;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: yaz-ccl.c,v $
- * Revision 1.11 2001-02-21 13:46:54 adam
+ * Revision 1.12 2001-03-07 13:24:40 adam
+ * Member and_not in Z_Operator is kept for backwards compatibility.
+ * Added support for definition of CCL operators in field spec file.
+ *
+ * Revision 1.11 2001/02/21 13:46:54 adam
* C++ fixes.
*
* Revision 1.10 2001/02/20 11:23:50 adam
{
case CCL_RPN_AND:
zo->which = Z_Operator_and;
- zo->u.op_and = odr_nullval();
+ zo->u.and_not = odr_nullval();
break;
case CCL_RPN_OR:
zo->which = Z_Operator_or;
- zo->u.op_or = odr_nullval();
+ zo->u.and_not = odr_nullval();
break;
case CCL_RPN_NOT:
zo->which = Z_Operator_and_not;
- zo->u.op_and_not = odr_nullval();
+ zo->u.and_not = odr_nullval();
break;
case CCL_RPN_PROX:
zo->which = Z_Operator_prox;