Not using the deprecated yaz-util.h any more
authorHeikki Levanto <heikki@indexdata.dk>
Fri, 10 Dec 2004 11:56:21 +0000 (11:56 +0000)
committerHeikki Levanto <heikki@indexdata.dk>
Fri, 10 Dec 2004 11:56:21 +0000 (11:56 +0000)
data1/d1_read.c
include/idzebra/data1.h
include/zebrautl.h
index/zsets.c
recctrl/inline.c
recctrl/marcomp.c
util/charmap.c
util/zebramap.c

index 763692c..f19b20e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: d1_read.c,v 1.11 2004-11-19 10:26:53 heikki Exp $
+/* $Id: d1_read.c,v 1.12 2004-12-10 11:56:21 heikki Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
    Index Data Aps
 
@@ -29,9 +29,18 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <stdio.h>
 #include <stdlib.h>
 
+/* Old yaz-util includes (FIXME - clean up what is not needed)*/
+#include <yaz/yconfig.h>
+#include <yaz/yaz-version.h>
 #include <yaz/xmalloc.h>
-#include <yaz/yaz-util.h>
-#include <yaz/ylog.h>
+#include <yaz/ylog.h>  
+#include <yaz/tpath.h>
+#include <yaz/options.h>
+#include <yaz/wrbuf.h>
+#include <yaz/nmem.h>
+#include <yaz/readconf.h>
+#include <yaz/marcdisp.h>
+#include <yaz/yaz-iconv.h>
 #include <d1_absyn.h>
 
 data1_node *data1_get_root_tag (data1_handle dh, data1_node *n)
index 5f65229..aec53b6 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: data1.h,v 1.4 2004-10-04 09:20:31 adam Exp $
+/* $Id: data1.h,v 1.5 2004-12-10 11:56:21 heikki Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
    Index Data Aps
 
@@ -30,8 +30,19 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <yaz/proto.h>
 
 #include <idzebra/version.h>
-#include <yaz/yaz-util.h>
+
+/* Old yaz-util includes */
+#include <yaz/yconfig.h>
+#include <yaz/yaz-version.h>
+#include <yaz/xmalloc.h>
+#include <yaz/ylog.h>  
+#include <yaz/tpath.h>
+#include <yaz/options.h>
 #include <yaz/wrbuf.h>
+#include <yaz/nmem.h>
+#include <yaz/readconf.h>
+#include <yaz/marcdisp.h>
+#include <yaz/yaz-iconv.h>
 
 #define d1_isspace(c) strchr(" \r\n\t\f", c)
 #define d1_isdigit(c) ((c) <= '9' && (c) >= '0')
index e54d1a7..9b1daf9 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebrautl.h,v 1.10 2004-11-19 10:26:55 heikki Exp $
+/* $Id: zebrautl.h,v 1.11 2004-12-10 11:56:21 heikki Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
    Index Data Aps
 
@@ -23,7 +23,19 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #ifndef ZEBRA_UTIL_H
 #define ZEBRA_UTIL_H
 
-#include <yaz/yaz-util.h>
+/* Old yaz-util includes */
+#include <yaz/yconfig.h>
+#include <yaz/yaz-version.h>
+#include <yaz/xmalloc.h>
+#include <yaz/ylog.h>  
+#include <yaz/tpath.h>
+#include <yaz/options.h>
+#include <yaz/wrbuf.h>
+#include <yaz/nmem.h>
+#include <yaz/readconf.h>
+#include <yaz/marcdisp.h>
+#include <yaz/yaz-iconv.h>
+
 #include <idzebra/res.h>
 #include <idzebra/version.h>
 
index 52cb82b..88ed57d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zsets.c,v 1.73 2004-12-02 17:27:04 adam Exp $
+/* $Id: zsets.c,v 1.74 2004-12-10 11:56:22 heikki Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
    Index Data Aps
 
@@ -71,6 +71,22 @@ struct zset_sort_info {
     struct zset_sort_entry **entries;
 };
 
+static int log_level_set=0;
+static int log_level_sorting=0;
+static int log_level_searchhits=0;
+static int log_level_searchterms=0;
+static int log_level_resultsets=0;
+
+static void loglevels()
+{
+    if (log_level_set)
+        return;
+    log_level_sorting = yaz_log_module_level("sorting");
+    log_level_searchhits = yaz_log_module_level("searchhits");
+    log_level_searchterms = yaz_log_module_level("searchterms");
+    log_level_resultsets = yaz_log_module_level("resultsets");
+}
+
 ZebraSet resultSetAddRPN (ZebraHandle zh, NMEM m,
                           Z_RPNQuery *rpn, int num_bases,
                           char **basenames, 
@@ -145,9 +161,12 @@ ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov)
     for (s = zh->sets; s; s = s->next)
         if (!strcmp (s->name, name))
             break;
+    
+    if (!log_level_set)
+        loglevels();
     if (s)
     {
-        yaz_log(YLOG_DEBUG, "updating result set %s", name);
+        yaz_log(log_level_resultsets, "updating result set %s", name);
         if (!ov || s->locked)
             return NULL;
         if (s->rset)
@@ -161,7 +180,7 @@ ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov)
     {
         const char *sort_max_str = zebra_get_resource(zh, "sortmax", "1000");
 
-        yaz_log(YLOG_DEBUG, "adding result set %s", name);
+        yaz_log(log_level_resultsets, "adding result set %s", name);
         s = (ZebraSet) xmalloc (sizeof(*s));
         s->next = zh->sets;
         zh->sets = s;
@@ -203,7 +222,7 @@ ZebraSet resultSetGet (ZebraHandle zh, const char *name)
             if (!s->term_entries && !s->rset && s->rpn)
             {
                 NMEM nmem = nmem_create ();
-                yaz_log(YLOG_LOG, "research %s", name);
+                yaz_log(log_level_resultsets, "research %s", name);
                 if (!s->rset_nmem)
                     s->rset_nmem=nmem_create();
                 s->rset =
@@ -220,6 +239,7 @@ void resultSetInvalidate (ZebraHandle zh)
 {
     ZebraSet s = zh->sets;
     
+    yaz_log(log_level_resultsets, "invalidating result sets");
     for (; s; s = s->next)
     {
         if (s->rset)
@@ -312,6 +332,8 @@ ZebraMetaRecord *zebra_meta_records_create (ZebraHandle zh, const char *name,
     int i;
     struct zset_sort_info *sort_info;
 
+    if (!log_level_set)
+        loglevels();
     if (!(sset = resultSetGet (zh, name)))
         return NULL;
     if (!(rset = sset->rset))
@@ -353,7 +375,7 @@ ZebraMetaRecord *zebra_meta_records_create (ZebraHandle zh, const char *name,
                 position = positions[i];
                 if (position > 0 && position <= sort_info->num_entries)
                 {
-                    yaz_log(YLOG_DEBUG, "got pos=%d (sorted)", position);
+                    yaz_log(log_level_sorting, "got pos=%d (sorted)", position);
                     sr[i].sysno = sort_info->entries[position-1]->sysno;
                     sr[i].score = sort_info->entries[position-1]->score;
                 }
@@ -381,7 +403,6 @@ ZebraMetaRecord *zebra_meta_records_create (ZebraHandle zh, const char *name,
             while (num_i < num && rset_read (rfd, &key, 0))
             {
                 zint this_sys = key.mem[0];
-               yaz_log(YLOG_LOG, "RSET READ " ZINT_FORMAT, this_sys);
                 if (this_sys != psysno)
                 {
                     psysno = this_sys;
@@ -399,7 +420,7 @@ ZebraMetaRecord *zebra_meta_records_create (ZebraHandle zh, const char *name,
                     if (position == positions[num_i])
                     {
                         sr[num_i].sysno = psysno;
-                        yaz_log(YLOG_DEBUG, "got pos=%d (unsorted)", position);
+                        yaz_log(log_level_sorting, "got pos=%d (unsorted)", position);
                         sr[num_i].score = -1;
                         num_i++;
                     }
@@ -564,7 +585,9 @@ void resultSetSort (ZebraHandle zh, NMEM nmem,
         zh->errCode = 230;
         return;
     }
-    yaz_log(YLOG_DEBUG, "result set sort input=%s output=%s",
+    if (!log_level_set)
+        loglevels();
+    yaz_log(log_level_sorting, "result set sort input=%s output=%s",
           *input_setnames, output_setname);
     sset = resultSetGet (zh, input_setnames[0]);
     if (!sset)
@@ -643,20 +666,20 @@ void resultSetSortSingle (ZebraHandle zh, NMEM nmem,
         switch (sk->which)
         {
         case Z_SortKey_sortField:
-            yaz_log(YLOG_DEBUG, "Sort: key %d is of type sortField", i+1);
+            yaz_log(log_level_sorting, "Sort: key %d is of type sortField", i+1);
             zh->errCode = 207;
             return;
         case Z_SortKey_elementSpec:
-            yaz_log(YLOG_DEBUG, "Sort: key %d is of type elementSpec", i+1);
+            yaz_log(log_level_sorting, "Sort: key %d is of type elementSpec", i+1);
             zh->errCode = 207;
             return;
         case Z_SortKey_sortAttributes:
-            yaz_log(YLOG_DEBUG, "Sort: key %d is of type sortAttributes", i+1);
+            yaz_log(log_level_sorting, "Sort: key %d is of type sortAttributes", i+1);
             sort_criteria[i].attrUse =
                 zebra_maps_sort (zh->reg->zebra_maps,
                                  sk->u.sortAttributes,
                                  &sort_criteria[i].numerical);
-            yaz_log(YLOG_DEBUG, "use value = %d", sort_criteria[i].attrUse);
+            yaz_log(log_level_sorting, "use value = %d", sort_criteria[i].attrUse);
             if (sort_criteria[i].attrUse == -1)
             {
                 zh->errCode = 116;
@@ -685,10 +708,10 @@ void resultSetSortSingle (ZebraHandle zh, NMEM nmem,
         }
     }
     rset_close (rfd);
-    yaz_log(YLOG_DEBUG, ZINT_FORMAT " keys, " ZINT_FORMAT " sysnos, sort",
+    yaz_log(log_level_sorting, ZINT_FORMAT " keys, " ZINT_FORMAT " sysnos, sort",
                    kno, sset->hits);   
     for (i = 0; i < numTerms; i++)
-        yaz_log(YLOG_LOG, "term=\"%s\" type=%s count=" ZINT_FORMAT,
+        yaz_log(log_level_sorting, "term=\"%s\" type=%s count=" ZINT_FORMAT,
                  terms[i]->name, terms[i]->flags, rset_count(terms[i]->rset));
     *sort_status = Z_SortResponse_success;
 }
@@ -721,6 +744,8 @@ void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset, NMEM nmem)
     zint esthits;
     double ratio;
 
+    if (!log_level_set)
+        loglevels();
     sort_info = zebraSet->sort_info;
     sort_info->num_entries = 0;
     zebraSet->hits = 0;
@@ -754,7 +779,7 @@ void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset, NMEM nmem)
             zint this_sys = key.mem[0]; /* FIXME - assumes scope==2 */
             zint seqno = key.mem[key.len-1]; /* FIXME - assumes scope==2 */
             kno++;
-           yaz_log(YLOG_LOG, "got sysno=%lld", this_sys);
+            key_logdump_txt(log_level_searchhits,&key," Got hit");
             if (this_sys != psysno)
             {
                 score = (*rc->calc) (handle, psysno);
@@ -771,7 +796,7 @@ void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset, NMEM nmem)
                 if (tot>0) {
                     ratio = cur/tot;
                     est = (zint)(0.5+zebraSet->hits/ratio);
-                    yaz_log(YLOG_LOG, "Estimating hits (%s) "
+                    yaz_log(log_level_searchhits, "Estimating hits (%s) "
                                   "%0.1f->" ZINT_FORMAT
                                   "; %0.1f->" ZINT_FORMAT,
                                   rset->control->desc,
@@ -795,11 +820,11 @@ void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset, NMEM nmem)
     }
     rset_close (rfd);
 
-    yaz_log(YLOG_DEBUG, ZINT_FORMAT " keys, " ZINT_FORMAT " sysnos, rank",
+    yaz_log(log_level_searchterms, ZINT_FORMAT " keys, " ZINT_FORMAT " sysnos, rank",
            kno, zebraSet->hits);
     for (i = 0; i < numTerms; i++)
     {
-        yaz_log(YLOG_LOG, "term=\"%s\" type=%s count=" ZINT_FORMAT,
+        yaz_log(log_level_searchterms, "term=\"%s\" type=%s count=" ZINT_FORMAT,
                  terms[i]->name, terms[i]->flags, rset_count(terms[i]->rset));
     }
 }
index d921715..96fd79d 100644 (file)
@@ -1,10 +1,22 @@
 /*
-    $Id: inline.c,v 1.3 2003-11-09 11:49:49 oleg Exp $
+    $Id: inline.c,v 1.4 2004-12-10 11:56:22 heikki Exp $
 */
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
-#include <yaz/yaz-util.h>
+/* Old yaz-util includes (FIXME - clean up what is not needed)*/
+#include <yaz/yconfig.h>
+#include <yaz/yaz-version.h>
+#include <yaz/xmalloc.h>
+#include <yaz/ylog.h>  
+#include <yaz/tpath.h>
+#include <yaz/options.h>
+#include <yaz/wrbuf.h>
+#include <yaz/nmem.h>
+#include <yaz/readconf.h>
+#include <yaz/marcdisp.h>
+#include <yaz/yaz-iconv.h>
+
 #include "inline.h"
 
 static void inline_destroy_subfield_recursive(inline_subfield *p);
index 6867897..fa898ba 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    $Id: marcomp.c,v 1.2 2003-02-28 14:34:37 adam Exp $
+    $Id: marcomp.c,v 1.3 2004-12-10 11:56:22 heikki Exp $
 
     marcomp.c - compiler of MARC statements.
 */
@@ -9,7 +9,19 @@
 #include <string.h>
 #include <ctype.h>
 
-#include <yaz/yaz-util.h>
+
+/* Old yaz-util includes (FIXME - clean up what is not needed)*/
+#include <yaz/yconfig.h>
+#include <yaz/yaz-version.h>
+#include <yaz/xmalloc.h>
+#include <yaz/ylog.h>  
+#include <yaz/tpath.h>
+#include <yaz/options.h>
+#include <yaz/wrbuf.h>
+#include <yaz/nmem.h>
+#include <yaz/readconf.h>
+#include <yaz/marcdisp.h>
+#include <yaz/yaz-iconv.h>
 
 #include "marcomp.h"
 
index fac1307..6161a43 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: charmap.c,v 1.31 2004-11-19 10:27:17 heikki Exp $
+/* $Id: charmap.c,v 1.32 2004-12-10 11:56:23 heikki Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
    Index Data Aps
 
@@ -33,9 +33,21 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 typedef unsigned ucs4_t;
 
-#include <yaz/yaz-util.h>
 #include <charmap.h>
 
+/* Old yaz-util includes */
+#include <yaz/yconfig.h>
+#include <yaz/yaz-version.h>
+#include <yaz/xmalloc.h>
+#include <yaz/ylog.h>  
+#include <yaz/tpath.h>
+#include <yaz/options.h>
+#include <yaz/wrbuf.h>
+#include <yaz/nmem.h>
+#include <yaz/readconf.h>
+#include <yaz/marcdisp.h>
+#include <yaz/yaz-iconv.h>
+
 
 #define CHR_MAXSTR 1024
 #define CHR_MAXEQUIV 32
index df1a50c..c73e78a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: zebramap.c,v 1.35 2004-11-19 10:27:18 heikki Exp $
+/* $Id: zebramap.c,v 1.36 2004-12-10 11:56:23 heikki Exp $
    Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
    Index Data Aps
 
@@ -25,8 +25,20 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <assert.h>
 #include <ctype.h>
 
-#include <yaz/yaz-util.h>
 #include <charmap.h>
+/* Old yaz-util includes */
+#include <yaz/yconfig.h>
+#include <yaz/yaz-version.h>
+#include <yaz/xmalloc.h>
+#include <yaz/ylog.h>  
+#include <yaz/tpath.h>
+#include <yaz/options.h>
+#include <yaz/wrbuf.h>
+#include <yaz/nmem.h>
+#include <yaz/readconf.h>
+#include <yaz/marcdisp.h>
+#include <yaz/yaz-iconv.h>
+
 #include <idzebra/zebramap.h>
 
 #define ZEBRA_MAP_TYPE_SORT  1