# Copyright (C) 1995, Index Data I/S
# All rights reserved.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile,v 1.16 1995-11-01 13:58:27 quinn Exp $
+# $Id: Makefile,v 1.17 1995-11-15 14:46:17 adam Exp $
SHELL=/bin/sh
RANLIB=ranlib
YAZ=../../yaz
YAZLIB=$(YAZ)/lib/libyaz.a
-#OSILIB=../../xtimosi/src/libmosi.a $(YAZ)/lib/librfc.a
+OSILIB=../../xtimosi/src/libmosi.a $(YAZ)/lib/librfc.a
#NETLIB=-lnsl -lsocket
INCLUDE=-I../include -I$(YAZ)/include
TPROG1=index
TPROG3=zserver
DEFS=$(INCLUDE)
O1 = main.o dir.o trav.o extract.o kinput.o kcompare.o \
- symtab.o text.o recctrl.o structrec.o
+ symtab.o text.o recctrl.o structrec.o recindex.o
O2 = kdump.o
O3 = zserver.o kcompare.o zrpn.o zsets.o text.o recctrl.o structrec.o \
- attribute.o
+ attribute.o recindex.o
CPP=$(CC) -E
all: $(TPROG1) $(TPROG2) $(TPROG3)
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: index.h,v $
- * Revision 1.19 1995-10-27 14:00:11 adam
+ * Revision 1.20 1995-11-15 14:46:18 adam
+ * Started work on better record management system.
+ *
+ * Revision 1.19 1995/10/27 14:00:11 adam
* Implemented detection of database availability.
*
* Revision 1.18 1995/10/17 18:02:08 adam
int index_char_cvt (int c);
int index_word_prefix (char *string, int attset_ordinal,
int local_attribute, char *databaseName);
+
--- /dev/null
+/*
+ * Copyright (C) 1994-1995, Index Data I/S
+ * All rights reserved.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: recindex.c,v $
+ * Revision 1.1 1995-11-15 14:46:20 adam
+ * Started work on better record management system.
+ *
+ */
+#include <stdio.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "recindex.h"
+
+#define REC_HEAD_MAGIC "rechead"
+
+static void rec_write_head (Records p)
+{
+ int r;
+
+ assert (p);
+ assert (p->fd != -1);
+ if (lseek (p->fd, (off_t) 0, SEEK_SET) == -1)
+ {
+ logf (LOG_FATAL|LOG_ERRNO, "lseek to 0 in %s", p->fname);
+ exit (1);
+ }
+ r = write (p->fd, &p->head, sizeof(p->head));
+ switch (r)
+ {
+ case -1:
+ logf (LOG_FATAL|LOG_ERRNO, "write head of %s", p->fname);
+ exit (1);
+ case sizeof(p->head):
+ break;
+ default:
+ logf (LOG_FATAL, "write head of %s. wrote %d", p->fname, r);
+ exit (1);
+ }
+}
+
+Records rec_open (int rw)
+{
+ Records p;
+ int r;
+
+ if (!(p = malloc (sizeof(*p))))
+ {
+ logf (LOG_FATAL|LOG_ERRNO, "malloc");
+ exit (1);
+ }
+ p->fname = "recindex";
+ p->fd = open (p->fname, rw ? (O_RDWR|O_CREAT) : O_RDONLY, 0666);
+ if (p->fd == -1)
+ {
+ logf (LOG_FATAL|LOG_ERRNO, "open %s", p->fname);
+ exit (1);
+ }
+ r = read (p->fd, &p->head, sizeof(p->head));
+ switch (r)
+ {
+ case -1:
+ logf (LOG_FATAL|LOG_ERRNO, "read %s", p->fname);
+ exit (1);
+ case 0:
+ p->head.no_records = 0;
+ p->head.freelist = 0;
+ if (rw)
+ rec_write_head (p);
+ break;
+ case sizeof(p->head):
+ if (memcmp (p->head.magic, REC_HEAD_MAGIC, sizeof(p->head.magic)))
+ {
+ logf (LOG_FATAL, "read %s. bad header", p->fname);
+ exit (1);
+ }
+ break;
+ default:
+ logf (LOG_FATAL, "read head of %s. expected %d. got %d",
+ p->fname, sizeof(p->head), r);
+ exit (1);
+ }
+ return p;
+}
+
+void rec_close (Records p)
+{
+ if (p->fd != -1)
+ close (p->fd);
+ free (p);
+}
+
+Record rec_get (Records p, int sysno)
+{
+ assert (p);
+ return NULL;
+}
+
+Record rec_new (Records p)
+{
+ assert (p);
+ return NULL;
+}
+
+void rec_put (Records p, Record rec)
+{
+ assert (p);
+}
--- /dev/null
+/*
+ * Copyright (C) 1994-1995, Index Data I/S
+ * All rights reserved.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: recindex.h,v $
+ * Revision 1.1 1995-11-15 14:46:21 adam
+ * Started work on better record management system.
+ *
+ */
+
+#include <alexutil.h>
+
+typedef struct records_info {
+ int fd;
+ char *fname;
+ struct records_head {
+ char magic[8];
+ int no_records;
+ int freelist;
+ } head;
+} *Records;
+
+typedef struct record_info {
+ int sysno;
+ char *type;
+ char *fname;
+ char *kinfo;
+} *Record;
+