Added CCL utility ccl_qual_line which adds CCL qualifier line consisting
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 18 Aug 2004 10:03:01 +0000 (10:03 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 18 Aug 2004 10:03:01 +0000 (10:03 +0000)
of name and value - ignoring empty lines and comments.

NEWS
include/yaz/ccl.h
src/cclqfile.c

diff --git a/NEWS b/NEWS
index 1428865..f184584 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 Possible compatibility problems with earlier versions marked with '*'.
 
 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.
 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.
index 14c34f3..d0fc3c3 100644 (file)
@@ -45,7 +45,7 @@
 /*
  * CCL - header file
  *
 /*
  * 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:
  *
  *
  * 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);
 
 /* 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 */
                                 const char *qual_name);
 
 /* Make CCL qualifier set */
index b562bac..a637b75 100644 (file)
@@ -44,7 +44,7 @@
 /* CCL qualifiers
  * Europagate, 1995
  *
 /* 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:
  *
  *
  * 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);
 }
 
        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
 /*
  * 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];
 void ccl_qual_file (CCL_bibset bibset, FILE *inf)
 {
     char line[256];
-    char *cp, *cp1;
-    char qual_name[128];
 
     while (fgets (line, 255, inf))
 
     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)
 }
 
 int ccl_qual_fname (CCL_bibset bibset, const char *fname)