Extra argument added to function chr_read_maptab (tab path).
[idzebra-moved-to-github.git] / index / zserver.c
index acaf62c..e9fc320 100644 (file)
@@ -4,7 +4,14 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: zserver.c,v $
- * Revision 1.45  1996-12-23 15:30:45  adam
+ * Revision 1.47  1997-09-04 13:58:36  adam
+ * New retrieve/extract method tellf (added).
+ * Added O_BINARY for open calls.
+ *
+ * Revision 1.46  1997/07/28 08:30:47  adam
+ * Server returns diagnostic 14 when record doesn't exist.
+ *
+ * Revision 1.45  1996/12/23 15:30:45  adam
  * Work on truncation.
  * Bug fix: result sets weren't deleted after server shut down.
  *
@@ -355,6 +362,11 @@ static off_t record_ext_seek (void *fh, off_t offset)
     return lseek (*((int*) fh), offset + record_offset, SEEK_SET);
 }
 
+static off_t record_ext_tell (void *fh)
+{
+    return lseek (*((int*) fh), 0, SEEK_CUR) - record_offset;
+}
+
 static int record_int_pos;
 static char *record_int_buf;
 static int record_int_len;
@@ -364,6 +376,11 @@ static off_t record_int_seek (void *fh, off_t offset)
     return (off_t) (record_int_pos = offset);
 }
 
+static off_t record_int_tell (void *fh)
+{
+    return (off_t) record_int_pos;
+}
+
 static int record_int_read (void *fh, char *buf, size_t count)
 {
     int l = record_int_len - record_int_pos;
@@ -390,12 +407,8 @@ static int record_fetch (ZServerInfo *zi, int sysno, int score, ODR stream,
     rec = rec_get (zi->records, sysno);
     if (!rec)
     {
-        char *msg = "Record is deleted\n";
-        *output_format = VAL_SUTRS;
-        *rec_bufp = msg;
-        *rec_lenp = strlen (msg);
         logf (LOG_DEBUG, "rec_get fail on sysno=%d", sysno);
-        return 0;
+        return 14;
     }
     file_type = rec->info[recInfo_fileType];
     fname = rec->info[recInfo_filename];
@@ -414,6 +427,7 @@ static int record_fetch (ZServerInfo *zi, int sysno, int score, ODR stream,
     {
         retrieveCtrl.readf = record_int_read;
         retrieveCtrl.seekf = record_int_seek;
+        retrieveCtrl.tellf = record_int_tell;
         record_int_len = rec->size[recInfo_storeData];
         record_int_buf = rec->info[recInfo_storeData];
         record_int_pos = 0;
@@ -421,23 +435,20 @@ static int record_fetch (ZServerInfo *zi, int sysno, int score, ODR stream,
     }
     else 
     {
-        if ((fd = open (fname, O_RDONLY)) == -1)
+        if ((fd = open (fname, O_BINARY|O_RDONLY)) == -1)
         {
-            char *msg = "Record doesn't exist\n";
-            logf (LOG_WARN|LOG_ERRNO, "Retrieve: Open record file %s", fname);
-            *output_format = VAL_SUTRS;
-            *rec_bufp = msg;
-            *rec_lenp = strlen (msg);
+            logf (LOG_WARN|LOG_ERRNO, "Retrieve fail; missing file: %s",
+                 fname);
             rec_rm (&rec);
-            return 0;     /* or 14: System error in presenting records */
+            return 14;
         }
-
         memcpy (&record_offset, rec->info[recInfo_offset],
                 sizeof(record_offset));
 
         retrieveCtrl.fh = &fd;
         retrieveCtrl.readf = record_ext_read;
         retrieveCtrl.seekf = record_ext_seek;
+        retrieveCtrl.tellf = record_ext_tell;
 
         record_ext_seek (retrieveCtrl.fh, 0);
     }