projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updated MSVC project files.
[idzebra-moved-to-github.git]
/
index
/
zebraapi.c
diff --git
a/index/zebraapi.c
b/index/zebraapi.c
index
30cf988
..
cf81adc
100644
(file)
--- a/
index/zebraapi.c
+++ b/
index/zebraapi.c
@@
-4,7
+4,19
@@
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zebraapi.c,v $
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zebraapi.c,v $
- * Revision 1.15 1999-02-17 12:18:12 adam
+ * Revision 1.19 1999-05-26 07:49:13 adam
+ * C++ compilation.
+ *
+ * Revision 1.18 1999/05/15 14:36:38 adam
+ * Updated dictionary. Implemented "compression" of dictionary.
+ *
+ * Revision 1.17 1999/05/12 13:08:06 adam
+ * First version of ISAMS.
+ *
+ * Revision 1.16 1999/02/19 10:38:30 adam
+ * Implemented chdir-setting.
+ *
+ * Revision 1.15 1999/02/17 12:18:12 adam
* Fixed zebra_close so that a NULL pointer is ignored.
*
* Revision 1.14 1999/02/02 14:51:11 adam
* Fixed zebra_close so that a NULL pointer is ignored.
*
* Revision 1.14 1999/02/02 14:51:11 adam
@@
-62,6
+74,7
@@
#ifdef WIN32
#include <io.h>
#include <process.h>
#ifdef WIN32
#include <io.h>
#include <process.h>
+#include <direct.h>
#else
#include <unistd.h>
#endif
#else
#include <unistd.h>
#endif
@@
-69,10
+82,26
@@
#include <diagbib1.h>
#include "zserver.h"
#include <diagbib1.h>
#include "zserver.h"
+static void zebra_chdir (ZebraHandle zh)
+{
+ const char *dir = res_get (zh->res, "chdir");
+ if (!dir)
+ return;
+ logf (LOG_DEBUG, "chdir %s", dir);
+#ifdef WIN32
+ _chdir(dir);
+#else
+ chdir (dir);
+#endif
+}
static int zebra_register_lock (ZebraHandle zh)
{
time_t lastChange;
static int zebra_register_lock (ZebraHandle zh)
{
time_t lastChange;
- int state = zebra_server_lock_get_state(zh, &lastChange);
+ int state;
+
+ zebra_chdir (zh);
+
+ state = zebra_server_lock_get_state(zh, &lastChange);
switch (state)
{
switch (state)
{
@@
-113,7
+142,7
@@
static int zebra_register_lock (ZebraHandle zh)
bf_cache (zh->bfs, state ? res_get (zh->res, "shadow") : NULL);
zh->registerState = state;
zh->records = rec_open (zh->bfs, 0);
bf_cache (zh->bfs, state ? res_get (zh->res, "shadow") : NULL);
zh->registerState = state;
zh->records = rec_open (zh->bfs, 0);
- if (!(zh->dict = dict_open (zh->bfs, FNAME_DICT, 40, 0)))
+ if (!(zh->dict = dict_open (zh->bfs, FNAME_DICT, 40, 0, 0)))
{
logf (LOG_WARN, "dict_open");
return -1;
{
logf (LOG_WARN, "dict_open");
return -1;
@@
-125,22
+154,31
@@
static int zebra_register_lock (ZebraHandle zh)
}
zh->isam = NULL;
zh->isamc = NULL;
}
zh->isam = NULL;
zh->isamc = NULL;
- if (!res_get_match (zh->res, "isam", "i", NULL))
+ zh->isams = NULL;
+ if (res_get_match (zh->res, "isam", "i", NULL))
{
{
- if (!(zh->isamc = isc_open (zh->bfs, FNAME_ISAMC,
- 0, key_isamc_m(zh->res))))
+ if (!(zh->isam = is_open (zh->bfs, FNAME_ISAM, key_compare, 0,
+ sizeof (struct it_key), zh->res)))
{
{
- logf (LOG_WARN, "isc_open");
+ logf (LOG_WARN, "is_open");
+ return -1;
+ }
+ }
+ else if (res_get_match (zh->res, "isam", "s", NULL))
+ {
+ if (!(zh->isams = isams_open (zh->bfs, FNAME_ISAMS, 0,
+ key_isams_m(zh->res))))
+ {
+ logf (LOG_WARN, "isams_open");
return -1;
}
return -1;
}
-
}
else
{
}
else
{
- if (!(zh->isam = is_open (zh->bfs, FNAME_ISAM, key_compare, 0,
- sizeof (struct it_key), zh->res)))
+ if (!(zh->isamc = isc_open (zh->bfs, FNAME_ISAMC,
+ 0, key_isamc_m(zh->res))))
{
{
- logf (LOG_WARN, "is_open");
+ logf (LOG_WARN, "isc_open");
return -1;
}
}
return -1;
}
}
@@
-178,13
+216,14
@@
static void zebra_register_unlock (ZebraHandle zh)
ZebraHandle zebra_open (const char *configName)
{
ZebraHandle zebra_open (const char *configName)
{
- ZebraHandle zh = xmalloc (sizeof(*zh));
+ ZebraHandle zh = (ZebraHandle) xmalloc (sizeof(*zh));
if (!(zh->res = res_open (configName)))
{
logf (LOG_WARN, "Failed to read resources `%s'", configName);
return NULL;
}
if (!(zh->res = res_open (configName)))
{
logf (LOG_WARN, "Failed to read resources `%s'", configName);
return NULL;
}
+ zebra_chdir (zh);
zebra_server_lock_init (zh);
zh->dh = data1_create ();
zh->bfs = bfs_create (res_get (zh->res, "register"));
zebra_server_lock_init (zh);
zh->dh = data1_create ();
zh->bfs = bfs_create (res_get (zh->res, "register"));
@@
-221,6
+260,7
@@
void zebra_close (ZebraHandle zh)
{
if (!zh)
return;
{
if (!zh)
return;
+ zebra_chdir (zh);
if (zh->records)
{
resultSetDestroy (zh);
if (zh->records)
{
resultSetDestroy (zh);
@@
-231,6
+271,8
@@
void zebra_close (ZebraHandle zh)
is_close (zh->isam);
if (zh->isamc)
isc_close (zh->isamc);
is_close (zh->isam);
if (zh->isamc)
isc_close (zh->isamc);
+ if (zh->isams)
+ isams_close (zh->isams);
rec_close (&zh->records);
zebra_register_unlock (zh);
}
rec_close (&zh->records);
zebra_register_unlock (zh);
}
@@
-259,7
+301,7
@@
struct map_baseinfo {
void map_basenames_func (void *vp, const char *name, const char *value)
{
void map_basenames_func (void *vp, const char *name, const char *value)
{
- struct map_baseinfo *p = vp;
+ struct map_baseinfo *p = (struct map_baseinfo *) vp;
int i, no;
char fromdb[128], todb[8][128];
int i, no;
char fromdb[128], todb[8][128];
@@
-340,7
+382,7
@@
void zebra_records_retrieve (ZebraHandle zh, ODR stream,
zh->errCode = 0;
zh->errString = NULL;
zh->errCode = 0;
zh->errString = NULL;
- pos_array = xmalloc (num_recs * sizeof(*pos_array));
+ pos_array = (int *) xmalloc (num_recs * sizeof(*pos_array));
for (i = 0; i<num_recs; i++)
pos_array[i] = recs[i].position;
for (i = 0; i<num_recs; i++)
pos_array[i] = recs[i].position;