Fixed bug in zebraIndexUnlock. On NT, the lock files wasn't removed.
[idzebra-moved-to-github.git] / index / kinput.c
index ac03e13..3ba3463 100644 (file)
@@ -1,10 +1,34 @@
 /*
- * Copyright (C) 1994-1996, Index Data I/S 
+ * Copyright (C) 1994-1998, Index Data I/S 
  * All rights reserved.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: kinput.c,v $
- * Revision 1.20  1996-11-01 08:58:41  adam
+ * Revision 1.26  1998-01-29 13:39:13  adam
+ * Compress ISAM is default.
+ *
+ * Revision 1.25  1997/09/17 12:19:14  adam
+ * Zebra version corresponds to YAZ version 1.4.
+ * Changed Zebra server so that it doesn't depend on global common_resource.
+ *
+ * Revision 1.24  1997/09/09 13:38:07  adam
+ * Partial port to WIN95/NT.
+ *
+ * Revision 1.23  1997/09/04 13:57:39  adam
+ * Added O_BINARY for open calls.
+ *
+ * Revision 1.22  1997/02/12 20:39:45  adam
+ * Implemented options -f <n> that limits the log to the first <n>
+ * records.
+ * Changed some log messages also.
+ *
+ * Revision 1.21  1996/11/08 11:10:23  adam
+ * Buffers used during file match got bigger.
+ * Compressed ISAM support everywhere.
+ * Bug fixes regarding masking characters in queries.
+ * Redesigned Regexp-2 queries.
+ *
+ * Revision 1.20  1996/11/01 08:58:41  adam
  * Interface to isamc system now includes update and delete.
  *
  * Revision 1.19  1996/10/29 14:09:46  adam
  */
 
 #include <fcntl.h>
+#ifdef WINDOWS
+#include <io.h>
+#else
 #include <unistd.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -122,7 +150,7 @@ void key_file_chunk_read (struct key_file *f)
     int nr = 0, r, fd;
     char fname[1024];
     getFnameTmp (fname, f->no);
-    fd = open (fname, O_RDONLY);
+    fd = open (fname, O_BINARY|O_RDONLY);
     if (fd == -1)
     {
         logf (LOG_FATAL|LOG_ERRNO, "cannot open %s", fname);
@@ -421,6 +449,7 @@ int heap_inpc (struct heap_info *hi)
 
         strcpy (this_name, hci.cur_name);
         logf (LOG_DEBUG, "inserting %s", 1+hci.cur_name);
+        no_diffs++;
         if ((dict_info = dict_lookup (hi->dict, hci.cur_name)))
         {
             memcpy (&isamc_p, dict_info+1, sizeof(ISAMC_P));
@@ -437,7 +466,6 @@ int heap_inpc (struct heap_info *hi)
                 if (isamc_p2 != isamc_p)
                     dict_insert (hi->dict, this_name,
                                  sizeof(ISAMC_P), &isamc_p2);
-
             }
         } 
         else
@@ -554,7 +582,11 @@ void progressFunc (struct key_file *keyp, void *info)
     p->totalOffset += keyp->buf_size;
 }
 
-void key_input (int nkeys, int cache)
+#ifndef R_OK
+#define R_OK 4
+#endif
+
+void key_input (BFiles bfs, int nkeys, int cache)
                 
 {
     Dict dict;
@@ -580,24 +612,26 @@ void key_input (int nkeys, int cache)
         if (!nkeys)
             return ;
     }
-    dict = dict_open (FNAME_DICT, cache, 1);
+    dict = dict_open (bfs, FNAME_DICT, cache, 1);
     if (!dict)
     {
         logf (LOG_FATAL, "dict_open fail");
         exit (1);
     }
-    if (res_get_match (common_resource, "isam", "c", NULL))
+    if (!res_get_match (common_resource, "isam", "i", NULL))
     {
-        isamc = isc_open (FNAME_ISAMC, 1, key_isamc_m ());
+        isamc = isc_open (bfs,
+                         FNAME_ISAMC, 1, key_isamc_m (common_resource));
         if (!isamc)
         {
-           logf (LOG_FATAL, "isc_open fail");
-           exit (1);
+            logf (LOG_FATAL, "isc_open fail");
+            exit (1);
         }
     }
     else
     {
-        isam = is_open (FNAME_ISAM, key_compare, 1, sizeof(struct it_key));
+        isam = is_open (bfs, FNAME_ISAM, key_compare, 1,
+                       sizeof(struct it_key), common_resource);
         if (!isam)
         {
             logf (LOG_FATAL, "is_open fail");
@@ -634,7 +668,7 @@ void key_input (int nkeys, int cache)
         is_close (isam);
     if (isamc)
         isc_close (isamc);
-    
+   
     for (i = 1; i<=nkeys; i++)
     {
         getFnameTmp (rbuf, i);