From: Adam Dickmeiss Date: Wed, 18 Aug 2004 10:03:01 +0000 (+0000) Subject: Added CCL utility ccl_qual_line which adds CCL qualifier line consisting X-Git-Tag: YAZ.2.0.24~36 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=5655212777a8fe68bf5cc1e563287c0f075a0ae5;p=yaz-moved-to-github.git Added CCL utility ccl_qual_line which adds CCL qualifier line consisting of name and value - ignoring empty lines and comments. --- diff --git a/NEWS b/NEWS index 1428865..f184584 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ Possible compatibility problems with earlier versions marked with '*'. +Added CCL utility ccl_qual_line which adds CCL qualifier line consisting +of name and value - ignoring empty lines and comments. + On Windows, the debug version DLL is now named yazdebug.dll (import library yazdebug.lib). WIN32 installer includes these files when development section is selected. diff --git a/include/yaz/ccl.h b/include/yaz/ccl.h index 14c34f3..d0fc3c3 100644 --- a/include/yaz/ccl.h +++ b/include/yaz/ccl.h @@ -45,7 +45,7 @@ /* * CCL - header file * - * $Id: ccl.h,v 1.15 2003-06-24 23:03:04 adam Exp $ + * $Id: ccl.h,v 1.16 2004-08-18 10:03:01 adam Exp $ * * Old Europagate Log: * @@ -299,8 +299,11 @@ YAZ_EXPORT void ccl_qual_file (CCL_bibset bibset, FILE *inf); /* Read CCL qualifier list spec from file inf */ YAZ_EXPORT int ccl_qual_fname (CCL_bibset bibset, const char *fname); -/* Add CCL qualifier by using single-line spec */ -YAZ_EXPORT void ccl_qual_fitem (CCL_bibset bibset, const char *cp, +/* Add CCL qualifier as line spec. Note: line is _modified_ */ +YAZ_EXPORT void ccl_qual_line(CCL_bibset bibset, char *line); + +/* Add CCL qualifier by using qual_name + value pair */ +YAZ_EXPORT void ccl_qual_fitem (CCL_bibset bibset, const char *value, const char *qual_name); /* Make CCL qualifier set */ diff --git a/src/cclqfile.c b/src/cclqfile.c index b562bac..a637b75 100644 --- a/src/cclqfile.c +++ b/src/cclqfile.c @@ -44,7 +44,7 @@ /* CCL qualifiers * Europagate, 1995 * - * $Id: cclqfile.c,v 1.1 2003-10-27 12:21:30 adam Exp $ + * $Id: cclqfile.c,v 1.2 2004-08-18 10:03:01 adam Exp $ * * Old Europagate Log: * @@ -214,6 +214,23 @@ void ccl_qual_fitem (CCL_bibset bibset, const char *cp, const char *qual_name) ccl_qual_field(bibset, cp, qual_name); } +void ccl_qual_line(CCL_bibset bibset, char *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) + return; /* also ignore empty lines */ + cp += no_scan; + cp1 = strchr(cp, '#'); + if (cp1) + *cp1 = '\0'; + ccl_qual_fitem (bibset, cp, qual_name); +} + /* * ccl_qual_file: Read bibset definition from file. * bibset: Bibset @@ -230,24 +247,9 @@ 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, *cp1; - char qual_name[128]; while (fgets (line, 255, inf)) - { - int no_scan = 0; - - cp = line; - if (*cp == '#') - continue; /* ignore lines starting with # */ - if (sscanf (cp, "%100s%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); - } + ccl_qual_line(bibset, line); } int ccl_qual_fname (CCL_bibset bibset, const char *fname)