New feature: databases. Implemented as prefix to words in dictionary.
[idzebra-moved-to-github.git] / index / kcompare.c
index d326493..82f9343 100644 (file)
@@ -4,7 +4,19 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: kcompare.c,v $
- * Revision 1.8  1995-09-28 09:19:42  adam
+ * Revision 1.12  1995-10-17 18:02:08  adam
+ * New feature: databases. Implemented as prefix to words in dictionary.
+ *
+ * Revision 1.11  1995/10/06  16:33:37  adam
+ * Use attribute mappings.
+ *
+ * Revision 1.10  1995/09/29  14:01:41  adam
+ * Bug fixes.
+ *
+ * Revision 1.9  1995/09/28  12:10:32  adam
+ * Bug fixes. Field prefix used in queries.
+ *
+ * Revision 1.8  1995/09/28  09:19:42  adam
  * xfree/xmalloc used everywhere.
  * Extract/retrieve method seems to work for text records.
  *
@@ -83,7 +95,48 @@ int key_compare (const void *p1, const void *p2)
     return 0;
 }
 
+int key_qsort_compare (const void *p1, const void *p2)
+{
+    int r;
+    size_t l;
+    char *cp1 = *(char **) p1;
+    char *cp2 = *(char **) p2;
+    if ((r = strcmp (cp1, cp2)))
+        return r;
+    l = strlen(cp1)+1;
+    if ((r = key_compare (cp1+l+1, cp2+l+1)))
+        return r;
+    return cp1[l] - cp2[l];
+}
+
 int index_char_cvt (int c)
 {
     return tolower (c);
 }
+
+int index_word_prefix (char *string, int attset_ordinal,
+                       int local_attribute,
+                       int num_bases,
+                       char **databaseNames)
+{
+    int i;
+    if (num_bases > 1)
+    {
+        sprintf (string, "%c%04d(", attset_ordinal + '0', local_attribute);
+        strcat (string, databaseNames[i]);
+        for (i = 1; i < num_bases; i++)
+        {
+            strcat (string, "|");
+            strcat (string, databaseNames[i]);
+        }
+        strcat (string, ")@");
+    }
+    else
+        sprintf (string, "%c%04d%s@", attset_ordinal + '0', local_attribute,
+                 *databaseNames);
+    for (i = 0; string[i]; i++)
+        string[i] = index_char_cvt (string[i]);
+    return i;
+}
+