Bug fixes. Field prefix used in queries.
[idzebra-moved-to-github.git] / index / extract.c
index 4808868..a7169f1 100644 (file)
@@ -4,7 +4,18 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: extract.c,v $
- * Revision 1.8  1995-09-14 07:48:22  adam
+ * Revision 1.11  1995-09-28 12:10:31  adam
+ * Bug fixes. Field prefix used in queries.
+ *
+ * Revision 1.10  1995/09/28  09:19:41  adam
+ * xfree/xmalloc used everywhere.
+ * Extract/retrieve method seems to work for text records.
+ *
+ * Revision 1.9  1995/09/27  12:22:28  adam
+ * More work on extract in record control.
+ * Field name is not in isam keys but in prefix in dictionary words.
+ *
+ * Revision 1.8  1995/09/14  07:48:22  adam
  * Record control management.
  *
  * Revision 1.7  1995/09/11  13:09:32  adam
@@ -38,7 +49,7 @@
 #include <ctype.h>
 
 #include <alexutil.h>
-#include <rectext.h>
+#include <recctrl.h>
 #include "index.h"
 
 static Dict file_idx;
@@ -120,7 +131,7 @@ void wordFlush (int sysno)
 static void wordInit (RecWord *p)
 {
     p->attrSet = 1;
-    p->attrUse = 1;
+    p->attrUse = 1016;
     p->which = Word_String;
 }
 
@@ -140,6 +151,8 @@ static void wordAdd (const RecWord *p)
         xfree (key_buf);
         key_buf = new_key_buf;
     }
+    key_offset += index_word_prefix (key_buf + key_offset,
+                                     p->attrSet, p->attrUse);
     switch (p->which)
     {
     case Word_String:
@@ -155,9 +168,7 @@ static void wordAdd (const RecWord *p)
     key_offset++;
 
     key.sysno = key_sysno;
-    key.attrSet = p->attrSet;
-    key.attrUse = p->attrUse;
-    key.seqno   = p->seqno;
+    key.seqno = p->seqno;
     memcpy (key_buf + key_offset, &key, sizeof(key));
     key_offset += sizeof(key);
 }
@@ -189,13 +200,15 @@ void file_extract (int cmd, const char *fname, const char *kname)
     sprintf (ext_res, "fileExtension.%s", ext);
     if (!(file_type = res_get (common_resource, ext_res)))
         return;
-    
+    if (!(rt = recType_byName (file_type)))
+        return;
     file_info = dict_lookup (file_idx, kname);
     if (!file_info)
     {
         sysno = sysno_next++;
         dict_insert (file_idx, kname, sizeof(sysno), &sysno);
         lseek (sys_idx_fd, sysno * SYS_IDX_ENTRY_LEN, SEEK_SET);
+        write (sys_idx_fd, file_type, strlen (file_type)+1);
         write (sys_idx_fd, kname, strlen(kname)+1);
     }
     else
@@ -206,10 +219,6 @@ void file_extract (int cmd, const char *fname, const char *kname)
         logf (LOG_WARN|LOG_ERRNO, "open %s", fname);
         return;
     }
-    if (!strcmp (file_type, "text"))
-        rt = recTypeText;
-    else
-        return;
     extractCtrl.inf = inf;
     extractCtrl.subType = "";
     extractCtrl.init = wordInit;