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
Version 5.9.0
[yaz-moved-to-github.git]
/
src
/
cclqfile.c
diff --git
a/src/cclqfile.c
b/src/cclqfile.c
index
4906af8
..
df98f33
100644
(file)
--- a/
src/cclqfile.c
+++ b/
src/cclqfile.c
@@
-1,13
+1,14
@@
-/*
- * Copyright (C) 1995-2008, Index Data ApS
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) Index Data
* See the file LICENSE for details.
* See the file LICENSE for details.
- *
- * $Id: cclqfile.c,v 1.12 2008-01-09 21:32:28 adam Exp $
*/
*/
-/**
+/**
* \file cclqfile.c
* \brief Implements parsing of CCL qualifier specs in files
*/
* \file cclqfile.c
* \brief Implements parsing of CCL qualifier specs in files
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
@@
-39,7
+40,7
@@
int ccl_qual_field2(CCL_bibset bibset, const char *cp, const char *qual_name,
yaz_tok_cfg_destroy(yt);
*addinfo = 0;
yaz_tok_cfg_destroy(yt);
*addinfo = 0;
-
+
t = yaz_tok_move(tp);
while (t == YAZ_TOK_STRING)
{
t = yaz_tok_move(tp);
while (t == YAZ_TOK_STRING)
{
@@
-81,14
+82,15
@@
int ccl_qual_field2(CCL_bibset bibset, const char *cp, const char *qual_name,
/* lead is first of a list of qualifier aliaeses */
/* qualifier alias: q1 q2 ... */
char *qlist[10];
/* lead is first of a list of qualifier aliaeses */
/* qualifier alias: q1 q2 ... */
char *qlist[10];
- int i = 0;
+ size_t i = 0;
qlist[i++] = lead_str;
qlist[i++] = lead_str;
- while ((t=yaz_tok_move(tp)) == YAZ_TOK_STRING)
+ while (t == YAZ_TOK_STRING)
{
if (i < sizeof(qlist)/sizeof(*qlist)-1)
qlist[i++] = xstrdup(yaz_tok_parse_string(tp));
{
if (i < sizeof(qlist)/sizeof(*qlist)-1)
qlist[i++] = xstrdup(yaz_tok_parse_string(tp));
+ t = yaz_tok_move(tp);
}
qlist[i] = 0;
yaz_tok_parse_destroy(tp);
}
qlist[i] = 0;
yaz_tok_parse_destroy(tp);
@@
-107,7
+109,7
@@
int ccl_qual_field2(CCL_bibset bibset, const char *cp, const char *qual_name,
goto out;
}
value_str = yaz_tok_parse_string(tp);
goto out;
}
value_str = yaz_tok_parse_string(tp);
-
+
if (sscanf(type_str, "%d", &type) == 1)
;
else if (strlen(type_str) != 1)
if (sscanf(type_str, "%d", &type) == 1)
;
else if (strlen(type_str) != 1)
@@
-130,7
+132,9
@@
int ccl_qual_field2(CCL_bibset bibset, const char *cp, const char *qual_name,
value = CCL_BIB1_REL_ORDER;
else if (!ccl_stricmp (value_str, "r"))
value = CCL_BIB1_REL_PORDER;
value = CCL_BIB1_REL_ORDER;
else if (!ccl_stricmp (value_str, "r"))
value = CCL_BIB1_REL_PORDER;
- break;
+ else if (!ccl_stricmp (value_str, "omiteq"))
+ value = CCL_BIB1_REL_OMIT_EQUALS;
+ break;
case 'p':
case 'P':
type = CCL_BIB1_POS;
case 'p':
case 'P':
type = CCL_BIB1_POS;
@@
-144,7
+148,9
@@
int ccl_qual_field2(CCL_bibset bibset, const char *cp, const char *qual_name,
value = CCL_BIB1_STR_AND_LIST;
if (!ccl_stricmp (value_str, "ol"))
value = CCL_BIB1_STR_OR_LIST;
value = CCL_BIB1_STR_AND_LIST;
if (!ccl_stricmp (value_str, "ol"))
value = CCL_BIB1_STR_OR_LIST;
- break;
+ if (!ccl_stricmp (value_str, "ag"))
+ value = CCL_BIB1_STR_AUTO_GROUP;
+ break;
case 't':
case 'T':
type = CCL_BIB1_TRU;
case 't':
case 'T':
type = CCL_BIB1_TRU;
@@
-156,7
+162,11
@@
int ccl_qual_field2(CCL_bibset bibset, const char *cp, const char *qual_name,
value = CCL_BIB1_TRU_CAN_BOTH;
else if (!ccl_stricmp (value_str, "n"))
value = CCL_BIB1_TRU_CAN_NONE;
value = CCL_BIB1_TRU_CAN_BOTH;
else if (!ccl_stricmp (value_str, "n"))
value = CCL_BIB1_TRU_CAN_NONE;
- break;
+ else if (!ccl_stricmp (value_str, "x"))
+ value = CCL_BIB1_TRU_CAN_REGEX;
+ else if (!ccl_stricmp (value_str, "z"))
+ value = CCL_BIB1_TRU_CAN_Z3958;
+ break;
case 'c':
case 'C':
type = CCL_BIB1_COM;
case 'c':
case 'C':
type = CCL_BIB1_COM;
@@
-226,12
+236,24
@@
void ccl_qual_field(CCL_bibset bibset, const char *cp, const char *qual_name)
yaz_log(YLOG_WARN, "ccl_qual_field2 fail: %s", addinfo);
}
yaz_log(YLOG_WARN, "ccl_qual_field2 fail: %s", addinfo);
}
-void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name)
+int ccl_qual_fitem2(CCL_bibset bibset, const char *cp, const char *qual_name,
+ const char **addinfo)
{
if (*qual_name == '@')
{
if (*qual_name == '@')
+ {
+ /* ccl_qual_add_special can not return error (yet) */
ccl_qual_add_special(bibset, qual_name+1, cp);
ccl_qual_add_special(bibset, qual_name+1, cp);
+ *addinfo = 0;
+ return 0;
+ }
else
else
- ccl_qual_field(bibset, cp, qual_name);
+ return ccl_qual_field2(bibset, cp, qual_name, addinfo);
+}
+
+void ccl_qual_fitem(CCL_bibset bibset, const char *cp, const char *qual_name)
+{
+ const char *addinfo = 0;
+ ccl_qual_fitem2(bibset, cp, qual_name, &addinfo);
}
void ccl_qual_buf(CCL_bibset bibset, const char *buf)
}
void ccl_qual_buf(CCL_bibset bibset, const char *buf)
@@
-241,7
+263,7
@@
void ccl_qual_buf(CCL_bibset bibset, const char *buf)
while (1)
{
const char *cp2 = cp1;
while (1)
{
const char *cp2 = cp1;
- int len;
+ size_t len;
while (*cp2 && !strchr("\r\n", *cp2))
cp2++;
len = cp2 - cp1;
while (*cp2 && !strchr("\r\n", *cp2))
cp2++;
len = cp2 - cp1;
@@
-264,7
+286,7
@@
void ccl_qual_line(CCL_bibset bibset, char *line)
int no_scan = 0;
char qual_name[128];
char *cp1, *cp = line;
int no_scan = 0;
char qual_name[128];
char *cp1, *cp = line;
-
+
if (*cp == '#')
return; /* ignore lines starting with # */
if (sscanf (cp, "%100s%n", qual_name, &no_scan) < 1)
if (*cp == '#')
return; /* ignore lines starting with # */
if (sscanf (cp, "%100s%n", qual_name, &no_scan) < 1)
@@
-284,8
+306,8
@@
void ccl_qual_line(CCL_bibset bibset, char *line)
* Each line format is:
* <name> <t>=<v> <t>=<v> ....
* Where <name> is name of qualifier;
* Each line format is:
* <name> <t>=<v> <t>=<v> ....
* Where <name> is name of qualifier;
- * <t>=<v> is a attribute definition pair where <t> is one of:
- * u(use), r(relation), p(position), t(truncation), c(completeness)
+ * <t>=<v> is a attribute definition pair where <t> is one of:
+ * u(use), r(relation), p(position), t(truncation), c(completeness)
* or plain integer.
* <v> is an integer or special pseudo-value.
*/
* or plain integer.
* <v> is an integer or special pseudo-value.
*/
@@
-310,6
+332,7
@@
int ccl_qual_fname (CCL_bibset bibset, const char *fname)
/*
* Local variables:
* c-basic-offset: 4
/*
* Local variables:
* c-basic-offset: 4
+ * c-file-style: "Stroustrup"
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab
* indent-tabs-mode: nil
* End:
* vim: shiftwidth=4 tabstop=8 expandtab