# Copyright (C) 1995, Index Data I/S
# All rights reserved.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.6 1995-09-05 15:28:39 adam Exp $
+# $Id: Makefile,v 1.7 1995-09-06 16:11:15 adam Exp $
SHELL=/bin/sh
RANLIB=ranlib
TPROG2=kdump
TPROG3=zserver
DEFS=$(INCLUDE)
-O1 = main.o dir.o trav.o extract.o kinput.o kcompare.o ksort.o
+O1 = main.o dir.o trav.o extract.o kinput.o kcompare.o ksort.o symtab.o
O2 = kdump.o
O3 = zserver.o kcompare.o zrpn.o zsets.o
CPP=cc -E
/*
- * Copyright (C) 1995, Index Data I/S
+ * Copyright (C) 1994-1995, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: dir.c,v $
- * Revision 1.4 1995-09-04 12:33:41 adam
+ * Revision 1.5 1995-09-06 16:11:16 adam
+ * Option: only one word key per file.
+ *
+ * Revision 1.4 1995/09/04 12:33:41 adam
* Various cleanup. YAZ util used instead.
*
* Revision 1.3 1995/09/01 14:06:35 adam
size_t idx = 0;
struct dir_entry *entry;
- logf (LOG_DEBUG, "dir_open %s", rep);
+ logf (LOG_LOG, "dir_open %s", rep);
if (!(dir = opendir(rep)))
{
logf (LOG_WARN|LOG_ERRNO, "opendir %s", rep);
/*
- * Copyright (C) 1995, Index Data I/S
+ * Copyright (C) 1994-1995, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: extract.c,v $
- * Revision 1.4 1995-09-05 15:28:39 adam
+ * Revision 1.5 1995-09-06 16:11:16 adam
+ * Option: only one word key per file.
+ *
+ * Revision 1.4 1995/09/05 15:28:39 adam
* More work on search engine.
*
* Revision 1.3 1995/09/04 12:33:41 adam
exit (1);
}
key_offset = 0;
- if (!(file_idx = dict_open (FNAME_FILE_DICT, 10, 1)))
+ if (!(file_idx = dict_open (FNAME_FILE_DICT, 40, 1)))
{
logf (LOG_FATAL, "dict_open fail of %s", "fileidx");
exit (1);
key_offset += sizeof(*k);
}
-void text_extract (SYSNO sysno, int cmd, const char *fname)
+void key_write_x (struct strtab *t, int cmd, struct it_key *k, const char *str)
+{
+ void **oldinfo;
+
+ if (strtab_src (t, str, &oldinfo))
+ ((struct it_key *) *oldinfo)->seqno++;
+ else
+ {
+ *oldinfo = xmalloc (sizeof(*k));
+ memcpy (*oldinfo, k, sizeof(*k));
+ ((struct it_key *) *oldinfo)->seqno = 1;
+ }
+}
+
+void key_rec_flush (const char *str, void *info, void *data)
+{
+ key_write (*((int*) data), (struct it_key *)info, str);
+ xfree (info);
+}
+
+void text_extract (struct strtab *t, SYSNO sysno, int cmd, const char *fname)
{
FILE *inf;
struct it_key k;
w[i] = 0;
k.seqno = seqno++;
+#if IT_KEY_HAVE_FIELD
k.field = 0;
- key_write (cmd, &k, w);
+#endif
+ key_write_x (t, cmd, &k, w);
}
if (c == EOF)
break;
char ext_res[128];
const char *file_type;
void *file_info;
+ struct strtab *t;
logf (LOG_DEBUG, "%c %s k=%s", cmd, fname, kname);
for (i = strlen(fname); --i >= 0; )
}
else
memcpy (&sysno, (char*) file_info+1, sizeof(sysno));
+ t = strtab_mk ();
if (!strcmp (file_type, "text"))
- text_extract (sysno, cmd, fname);
+ text_extract (t, sysno, cmd, fname);
+ strtab_del (t, key_rec_flush, &cmd);
}
/*
- * Copyright (C) 1995, Index Data I/S
+ * Copyright (C) 1994-1995, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: index.h,v $
- * Revision 1.6 1995-09-05 15:28:39 adam
+ * Revision 1.7 1995-09-06 16:11:16 adam
+ * Option: only one word key per file.
+ *
+ * Revision 1.6 1995/09/05 15:28:39 adam
* More work on search engine.
*
* Revision 1.5 1995/09/04 12:33:42 adam
#include <dict.h>
#include <isam.h>
+#define IT_KEY_HAVE_FIELD 0
+
struct it_key {
int sysno;
int seqno;
+#if IT_KEY_HAVE_FIELD
int field;
+#endif
};
struct dir_entry {
#define FNAME_FILE_DICT "filedict"
#define FNAME_SYS_IDX "sysidx"
#define SYS_IDX_ENTRY_LEN 120
+
+struct strtab *strtab_mk (void);
+int strtab_src (struct strtab *t, const char *name, void ***infop);
+void strtab_del (struct strtab *t,
+ void (*func)(const char *name, void *info, void *data),
+ void *data);
/*
- * Copyright (C) 1995, Index Data I/S
+ * Copyright (C) 1994-1995, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: kcompare.c,v $
- * Revision 1.1 1995-09-04 09:10:36 adam
+ * Revision 1.2 1995-09-06 16:11:17 adam
+ * Option: only one word key per file.
+ *
+ * Revision 1.1 1995/09/04 09:10:36 adam
* More work on index add/del/update.
* Merge sort implemented.
* Initial work on z39 server.
memcpy (&i2, p2, sizeof(i2));
if ( i1.sysno != i2.sysno)
return i1.sysno - i2.sysno;
+#if IT_KEY_HAVE_FIELD
if ( i1.seqno != i2.seqno)
return i1.seqno - i2.seqno;
return i1.field - i2.field;
+#else
+ return i1.seqno - i2.seqno;
+#endif
}
int key_compare_x (const struct it_key *i1, const struct it_key *i2)
{
if ( i1->sysno != i2->sysno)
return i1->sysno - i2->sysno;
+#if IT_KEY_HAVE_FIELD
if ( i1->seqno != i2->seqno)
return i1->seqno - i2->seqno;
return i1->field - i2->field;
+#else
+ return i1->seqno - i2->seqno;
+#endif
}
/*
- * Copyright (C) 1995, Index Data I/S
+ * Copyright (C) 1994-1995, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: kdump.c,v $
- * Revision 1.2 1995-09-04 12:33:42 adam
+ * Revision 1.3 1995-09-06 16:11:17 adam
+ * Option: only one word key per file.
+ *
+ * Revision 1.2 1995/09/04 12:33:42 adam
* Various cleanup. YAZ util used instead.
*
* Revision 1.1 1995/09/04 09:10:36 adam
/*
- * Copyright (C) 1995, Index Data I/S
+ * Copyright (C) 1994-1995, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: kinput.c,v $
- * Revision 1.2 1995-09-04 12:33:42 adam
+ * Revision 1.3 1995-09-06 16:11:17 adam
+ * Option: only one word key per file.
+ *
+ * Revision 1.2 1995/09/04 12:33:42 adam
* Various cleanup. YAZ util used instead.
*
* Revision 1.1 1995/09/04 09:10:37 adam
logf (LOG_FATAL, "dict_open fail of `%s'", dict_fname);
exit (1);
}
- isam = is_open (isam_fname, key_compare, 1);
+ isam = is_open (isam_fname, key_compare, 1, sizeof(struct it_key));
if (!isam)
{
logf (LOG_FATAL, "is_open fail of `%s'", isam_fname);
/*
- * Copyright (C) 1995, Index Data I/S
+ * Copyright (C) 1994-1995, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: main.c,v $
- * Revision 1.7 1995-09-05 15:28:39 adam
+ * Revision 1.8 1995-09-06 16:11:18 adam
+ * Option: only one word key per file.
+ *
+ * Revision 1.7 1995/09/05 15:28:39 adam
* More work on search engine.
*
* Revision 1.6 1995/09/04 12:33:43 adam
key_flush ();
if (!key_close ())
exit (0);
- logf (LOG_DEBUG, "Sorting");
- if (!key_sort ("keys.tmp", 1000000))
+ logf (LOG_LOG, "Sorting");
+ if (!key_sort ("keys.tmp", 3000000))
exit (0);
- logf (LOG_DEBUG, "Input");
- key_input (FNAME_WORD_DICT, FNAME_WORD_ISAM, "keys.tmp", 50);
+ logf (LOG_LOG, "Input");
+ key_input (FNAME_WORD_DICT, FNAME_WORD_ISAM, "keys.tmp", 60);
exit (0);
}
--- /dev/null
+/*
+ * Copyright (C) 1994-1995, Index Data I/S
+ * All rights reserved.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: symtab.c,v $
+ * Revision 1.1 1995-09-06 16:11:18 adam
+ * Option: only one word key per file.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include <alexutil.h>
+#include "index.h"
+
+struct strentry {
+ char *name;
+ void *info;
+ struct strentry *next;
+};
+
+#define STR_HASH 401
+
+struct strtab {
+ struct strentry *ar[STR_HASH];
+};
+
+struct strtab *strtab_mk (void)
+{
+ int i;
+ struct strtab *p = xmalloc (sizeof (*p));
+ for (i=0; i<STR_HASH; i++)
+ p->ar[i] = NULL;
+ return p;
+}
+
+int strtab_src (struct strtab *t, const char *name, void ***infop)
+{
+ unsigned hash = 0;
+ int i;
+ struct strentry *e;
+
+ for (i=0; name[i]; i++)
+ hash += hash*65519 + name[i];
+ hash = hash % STR_HASH;
+ for (e = t->ar[hash]; e; e = e->next)
+ if (!strcmp(e->name, name))
+ {
+ *infop = &e->info;
+ return 1;
+ }
+ e = xmalloc (sizeof(*e));
+ e->name = xmalloc (strlen(name)+1);
+ strcpy (e->name, name);
+ e->next = t->ar[hash];
+ t->ar[hash] = e;
+ *infop = &e->info;
+ return 0;
+}
+
+void strtab_del (struct strtab *t,
+ void (*func)(const char *name, void *info, void *data),
+ void *data)
+{
+ int i;
+ struct strentry *e, *e1;
+
+ for (i = 0; i<STR_HASH; i++)
+ for (e = t->ar[i]; e; e = e1)
+ {
+ e1 = e->next;
+ (*func)(e->name, e->info, data);
+ free (e->name);
+ free (e);
+ }
+ free (t);
+}
/*
- * Copyright (C) 1995, Index Data I/S
+ * Copyright (C) 1994-1995, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: trav.c,v $
- * Revision 1.2 1995-09-04 12:33:43 adam
+ * Revision 1.3 1995-09-06 16:11:18 adam
+ * Option: only one word key per file.
+ *
+ * Revision 1.2 1995/09/04 12:33:43 adam
* Various cleanup. YAZ util used instead.
*
* Revision 1.1 1995/09/01 14:06:36 adam
/*
- * Copyright (C) 1995, Index Data I/S
+ * Copyright (C) 1994-1995, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zrpn.c,v $
- * Revision 1.5 1995-09-06 10:33:04 adam
+ * Revision 1.6 1995-09-06 16:11:18 adam
+ * Option: only one word key per file.
+ *
+ * Revision 1.5 1995/09/06 10:33:04 adam
* More work on present. Some log messages removed.
*
* Revision 1.4 1995/09/05 15:28:40 adam
/*
- * Copyright (C) 1995, Index Data I/S
+ * Copyright (C) 1994-1995, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.c,v $
- * Revision 1.4 1995-09-06 10:33:04 adam
+ * Revision 1.5 1995-09-06 16:11:18 adam
+ * Option: only one word key per file.
+ *
+ * Revision 1.4 1995/09/06 10:33:04 adam
* More work on present. Some log messages removed.
*
* Revision 1.3 1995/09/05 15:28:40 adam
r.errstring = "dict_open fail: filedict";
return &r;
}
- if (!(server_info.fileDict = dict_open (FNAME_FILE_DICT, 5, 0)))
+ if (!(server_info.fileDict = dict_open (FNAME_FILE_DICT, 10, 0)))
{
r.errcode = 1;
r.errstring = "dict_open fail: filedict";
return &r;
}
- if (!(server_info.wordDict = dict_open (FNAME_WORD_DICT, 20, 0)))
+ if (!(server_info.wordDict = dict_open (FNAME_WORD_DICT, 40, 0)))
{
dict_close (server_info.fileDict);
r.errcode = 1;
r.errstring = "dict_open fail: worddict";
return &r;
}
- if (!(server_info.wordIsam = is_open (FNAME_WORD_ISAM, key_compare, 0)))
+ if (!(server_info.wordIsam = is_open (FNAME_WORD_ISAM, key_compare, 0,
+ sizeof (struct it_key))))
{
dict_close (server_info.wordDict);
dict_close (server_info.fileDict);
/*
- * Copyright (C) 1995, Index Data I/S
+ * Copyright (C) 1994-1995, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.h,v $
- * Revision 1.1 1995-09-05 15:28:40 adam
+ * Revision 1.2 1995-09-06 16:11:19 adam
+ * Option: only one word key per file.
+ *
+ * Revision 1.1 1995/09/05 15:28:40 adam
* More work on search engine.
*
*/
/*
- * Copyright (C) 1995, Index Data I/S
+ * Copyright (C) 1994-1995, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zsets.c,v $
- * Revision 1.2 1995-09-06 10:33:04 adam
+ * Revision 1.3 1995-09-06 16:11:19 adam
+ * Option: only one word key per file.
+ *
+ * Revision 1.2 1995/09/06 10:33:04 adam
* More work on present. Some log messages removed.
*
* Revision 1.1 1995/09/05 15:28:40 adam