X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=ccl%2Fcclqfile.c;h=76fb21f54bc55befc6c5065f52519e1d46d34877;hb=26d07328e36c41d39216d66d742d133cf7512995;hp=9e0957a311fead959f5dd38b4bc0fc585ef7771c;hpb=c126b2a625462f95475f00efdfdf9ce41a0e9c79;p=yaz-moved-to-github.git diff --git a/ccl/cclqfile.c b/ccl/cclqfile.c index 9e0957a..76fb21f 100644 --- a/ccl/cclqfile.c +++ b/ccl/cclqfile.c @@ -45,7 +45,24 @@ * Europagate, 1995 * * $Log: cclqfile.c,v $ - * Revision 1.4 2000-01-31 13:15:21 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 + * Fixed nasty bug introduced by previous commit (attribute sets not + * properly allocated). + * + * Revision 1.6 2000/11/16 09:58:02 adam + * Implemented local AttributeSet setting for CCL field maps. + * + * Revision 1.5 2000/10/17 19:50:28 adam + * Implemented and-list and or-list for CCL module. + * + * Revision 1.4 2000/01/31 13:15:21 adam * Removed uses of assert(3). Cleanup of ODR. CCL parser update so * that some characters are not surrounded by spaces in resulting term. * ILL-code updates. @@ -78,27 +95,37 @@ #include -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_type[128]; + char qual_spec[128]; int no_scan; - int pair[128]; + int pair[256]; + char *attsets[128]; int pair_no = 0; - while (1) + while (pair_no < 128) { - char *qual_value; - char *split; - - if (sscanf (cp, "%s%n", qual_type, &no_scan) != 1) - break; + char *qual_value, *qual_type; + char *split, *setp; - if (!(split = strchr (qual_type, '='))) + if (sscanf (cp, "%s%n", qual_spec, &no_scan) != 1) + break; + + if (!(split = strchr (qual_spec, '='))) break; cp += no_scan; *split++ = '\0'; - while (1) + + setp = strchr (qual_spec, ','); + if (setp) + { + *setp++ = '\0'; + qual_type = setp; + } + else + qual_type = qual_spec; + while (pair_no < 128) { int type, value; @@ -127,6 +154,10 @@ void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name) type = CCL_BIB1_STR; if (!ccl_stricmp (qual_value, "pw")) value = CCL_BIB1_STR_WP; + if (!ccl_stricmp (qual_value, "al")) + value = CCL_BIB1_STR_AND_LIST; + if (!ccl_stricmp (qual_value, "ol")) + value = CCL_BIB1_STR_OR_LIST; break; case 't': case 'T': @@ -143,18 +174,33 @@ void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name) case 'c': case 'C': type = CCL_BIB1_COM; - break; + break; default: type = atoi (qual_type); } pair[pair_no*2] = type; pair[pair_no*2+1] = value; + if (setp) + { + attsets[pair_no] = (char*) malloc (strlen(qual_spec)+1); + strcpy (attsets[pair_no], qual_spec); + } + else + attsets[pair_no] = 0; pair_no++; if (!split) break; } } - ccl_qual_add (bibset, qual_name, pair_no, pair); + 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); } /* @@ -173,7 +219,7 @@ void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name) void ccl_qual_file (CCL_bibset bibset, FILE *inf) { char line[256]; - char *cp; + char *cp, *cp1; char qual_name[128]; int no_scan; @@ -185,6 +231,19 @@ void ccl_qual_file (CCL_bibset bibset, FILE *inf) 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); } } + +int ccl_qual_fname (CCL_bibset bibset, const char *fname) +{ + FILE *inf; + inf = fopen (fname, "r"); + if (!inf) + return -1; + ccl_qual_file (bibset, inf); + return 0; +}