Compact use/set bytes used in search service.
[idzebra-moved-to-github.git] / index / zserver.c
index 88a90a4..b6b3d00 100644 (file)
@@ -4,7 +4,14 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zserver.c,v $
- * Revision 1.35  1996-03-26 16:01:14  adam
+ * Revision 1.37  1996-05-14 06:16:48  adam
+ * Compact use/set bytes used in search service.
+ *
+ * Revision 1.36  1996/05/01 13:46:37  adam
+ * First work on multiple records in one file.
+ * New option, -offset, to the "unread" command in the filter module.
+ *
+ * Revision 1.35  1996/03/26  16:01:14  adam
  * New setting lockPath: directory of various lock files.
  *
  * Revision 1.34  1996/03/20  09:36:46  adam
@@ -172,6 +179,7 @@ static int register_lock (ZServerInfo *zi)
     zi->registerChange = lastChange;
     if (zi->records)
     {
+        zebTargetInfo_close (zi->zti, 0);
         dict_close (zi->wordDict);
         is_close (zi->wordIsam);
         rec_close (&zi->records);
@@ -184,6 +192,7 @@ static int register_lock (ZServerInfo *zi)
     if (!(zi->wordIsam = is_open (FNAME_WORD_ISAM, key_compare, 0,
                                   sizeof (struct it_key))))
         return -1;
+    zi->zti = zebTargetInfo_open (zi->records, 0);
     return 0;
 }
 
@@ -270,15 +279,27 @@ bend_searchresult *bend_search (void *handle, bend_searchrequest *q, int *fd)
     return &r;
 }
 
+static int record_offset;
+
 static int record_ext_read (void *fh, char *buf, size_t count)
 {
     return read (*((int*) fh), buf, count);
 }
 
+static off_t record_ext_seek (void *fh, off_t offset)
+{
+    return lseek (*((int*) fh), offset + record_offset, SEEK_SET);
+}
+
 static int record_int_pos;
 static char *record_int_buf;
 static int record_int_len;
 
+static off_t record_int_seek (void *fh, off_t offset)
+{
+    return (off_t) (record_int_pos = offset);
+}
+
 static int record_int_read (void *fh, char *buf, size_t count)
 {
     int l = record_int_len - record_int_pos;
@@ -325,6 +346,7 @@ static int record_fetch (ZServerInfo *zi, int sysno, int score, ODR stream,
     if (rec->size[recInfo_storeData] > 0)
     {
         retrieveCtrl.readf = record_int_read;
+        retrieveCtrl.seekf = record_int_seek;
         record_int_len = rec->size[recInfo_storeData];
         record_int_buf = rec->info[recInfo_storeData];
         record_int_pos = 0;
@@ -342,8 +364,15 @@ static int record_fetch (ZServerInfo *zi, int sysno, int score, ODR stream,
             rec_rm (&rec);
             return 0;     /* or 14: System error in presenting records */
         }
+
+        memcpy (&record_offset, rec->info[recInfo_offset],
+                sizeof(record_offset));
+
         retrieveCtrl.fh = &fd;
         retrieveCtrl.readf = record_ext_read;
+        retrieveCtrl.seekf = record_ext_seek;
+
+        record_ext_seek (retrieveCtrl.fh, 0);
     }
     retrieveCtrl.subType = subType;
     retrieveCtrl.localno = sysno;