# Copyright (C) 1994-1998, Index Data
# All rights reserved.
# Sebastian Hammer, Adam Dickmeiss
-# $Id: Makefile.in,v 1.2 1998-10-28 15:20:46 adam Exp $
+# $Id: Makefile.in,v 1.3 1999-03-09 13:07:05 adam Exp $
SHELL=/bin/sh
DEFS=$(CDEFS) $(INCLUDE)
LIB=../lib/dict.a
PO = scan.o dopen.o dclose.o drdwr.o open.o close.o insert.o lookup.o \
- lookupec.o lookgrep.o delete.o
+ lookupec.o lookgrep.o delete.o dcompact.o
all: $(LIB)
--- /dev/null
+/*
+ * Copyright (C) 1994-1999, Index Data
+ * All rights reserved.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: dcompact.c,v $
+ * Revision 1.1 1999-03-09 13:07:06 adam
+ * Work on dict_compact routine.
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <log.h>
+#include <dict.h>
+
+int dict_compact (BFiles bfs, const char *from_name, const char *to_name)
+{
+ int no_dir = 0;
+ Dict from, to;
+ int *map, i;
+ map = xmalloc (100);
+ from = dict_open (bfs, from_name, 0, 0);
+ if (!from)
+ return -1;
+ map = xmalloc ((from->head.last+1) * sizeof(*map));
+ for (i = 0; i <= from->head.last; i++)
+ map[i] = -1;
+ to = dict_open (bfs, to_name, 0, 1);
+ if (!to)
+ return -1;
+ map[0] = 0;
+ map[1] = DICT_pagesize(from);
+
+ for (i = 1; i < from->head.last; i++)
+ {
+ void *buf;
+ logf (LOG_LOG, "map[%d] = %d", i, map[i]);
+ dict_bf_readp (from->dbf, i, &buf);
+ map[i+1] = map[i] + DICT_size(buf);
+ no_dir += DICT_nodir(buf);
+ }
+ logf (LOG_LOG, "map[%d] = %d", i, map[i]);
+ logf (LOG_LOG, "nodir = %d", no_dir);
+ dict_close (from);
+ dict_close (to);
+ return 0;
+}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: open.c,v $
- * Revision 1.13 1999-02-02 14:50:27 adam
+ * Revision 1.14 1999-03-09 13:07:06 adam
+ * Work on dict_compact routine.
+ *
+ * Revision 1.13 1999/02/02 14:50:27 adam
* Updated WIN32 code specific sections. Changed header.
*
* Revision 1.12 1997/09/17 12:19:07 adam
dict = xmalloc (sizeof(*dict));
+ if (cache < 5)
+ cache = 5;
sprintf (resource_str, "dict.%s.pagesize", name);
dict->grep_cmap = NULL;
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: dict.h,v $
- * Revision 1.27 1999-02-02 14:50:32 adam
+ * Revision 1.28 1999-03-09 13:07:06 adam
+ * Work on dict_compact routine.
+ *
+ * Revision 1.27 1999/02/02 14:50:32 adam
* Updated WIN32 code specific sections. Changed header.
*
* Revision 1.26 1997/09/18 08:59:18 adam
void dict_grep_cmap (Dict dict, void *vp,
const char **(*cmap)(void *vp,
const char **from, int len));
+int dict_compact (BFiles bfs, const char *from, const char *to);
#define DICT_EOS 0