/*
- * Copyright (C) 1994-1996, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: dirs.c,v $
- * Revision 1.13 1997-09-09 13:38:06 adam
+ * Revision 1.14 1998-01-12 15:04:07 adam
+ * The test option (-s) only uses read-lock (and not write lock).
+ *
+ * Revision 1.13 1997/09/09 13:38:06 adam
* Partial port to WIN95/NT.
*
* Revision 1.12 1996/11/08 11:10:13 adam
struct dirs_info {
Dict dict;
+ int rw;
int no_read;
int no_cur;
int no_max;
return 0;
}
-struct dirs_info *dirs_open (Dict dict, const char *rep)
+struct dirs_info *dirs_open (Dict dict, const char *rep, int rw)
{
struct dirs_info *p;
int before = 0, after;
logf (LOG_DEBUG, "dirs_open %s", rep);
p = xmalloc (sizeof (*p));
p->dict = dict;
+ p->rw = rw;
strcpy (p->prefix, rep);
p->prelen = strlen(p->prefix);
strcpy (p->nextpath, rep);
sprintf (path, "%s%s", p->prefix, src);
logf (LOG_DEBUG, "dirs_mkdir %s", path);
- dict_insert (p->dict, path, sizeof(mtime), &mtime);
+ if (p->rw)
+ dict_insert (p->dict, path, sizeof(mtime), &mtime);
}
void dirs_rmdir (struct dirs_info *p, const char *src)
sprintf (path, "%s%s", p->prefix, src);
logf (LOG_DEBUG, "dirs_rmdir %s", path);
- dict_delete (p->dict, path);
+ if (p->rw)
+ dict_delete (p->dict, path);
}
void dirs_add (struct dirs_info *p, const char *src, int sysno, time_t mtime)
logf (LOG_DEBUG, "dirs_add %s", path);
memcpy (info, &sysno, sizeof(sysno));
memcpy (info+sizeof(sysno), &mtime, sizeof(mtime));
- dict_insert (p->dict, path, sizeof(sysno)+sizeof(mtime), info);
+ if (p->rw)
+ dict_insert (p->dict, path, sizeof(sysno)+sizeof(mtime), info);
}
void dirs_del (struct dirs_info *p, const char *src)
sprintf (path, "%s%s", p->prefix, src);
logf (LOG_DEBUG, "dirs_del %s", path);
- dict_delete (p->dict, path);
+ if (p->rw)
+ dict_delete (p->dict, path);
}
void dirs_free (struct dirs_info **pp)
/*
- * Copyright (C) 1994-1997, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: extract.c,v $
- * Revision 1.76 1997-10-27 14:33:04 adam
+ * Revision 1.77 1998-01-12 15:04:08 adam
+ * The test option (-s) only uses read-lock (and not write lock).
+ *
+ * Revision 1.76 1997/10/27 14:33:04 adam
* Moved towards generic character mapping depending on "structure"
* field in abstract syntax file. Fixed a few memory leaks. Fixed
* bug with negative integers when doing searches with relational
}
}
-void key_open (BFiles bfs, int mem)
+int key_open (BFiles bfs, int mem, int rw)
{
if (!mem)
mem = atoi(res_get_def (common_resource, "memMax", "4"))*1024*1024;
key_buf_used = 0;
key_file_no = 0;
- if (!(matchDict = dict_open (bfs, GMATCH_DICT, 50, 1)))
+ if (!(matchDict = dict_open (bfs, GMATCH_DICT, 50, rw)))
{
logf (LOG_FATAL, "dict_open fail of %s", GMATCH_DICT);
- exit (1);
+ return -1;
}
assert (!records);
- records = rec_open (bfs, 1);
-#if 1
- zti = zebTargetInfo_open (records, 1);
-#endif
+ records = rec_open (bfs, rw);
+ if (!records)
+ {
+ dict_close (matchDict);
+ return -1;
+ }
+ zti = zebTargetInfo_open (records, rw);
+ if (!zti)
+ {
+ rec_close (&records);
+ dict_close (matchDict);
+ return -1;
+ }
+ return 0;
}
struct encode_info {
if (!(outf = fopen (out_fname, "w")))
{
- logf (LOG_FATAL|LOG_ERRNO, "fopen (4) %s", out_fname);
+ logf (LOG_FATAL|LOG_ERRNO, "fopen %s", out_fname);
exit (1);
}
logf (LOG_LOG, "writing section %d", key_file_no);
if (!(outf = fopen (out_fname, "w")))
{
- logf (LOG_FATAL|LOG_ERRNO, "fopen (4) %s", out_fname);
+ logf (LOG_FATAL|LOG_ERRNO, "fopen %s", out_fname);
exit (1);
}
logf (LOG_LOG, "writing section %d", key_file_no);
extractCtrl.tellf = file_tell;
extractCtrl.endf = file_end;
extractCtrl.zebra_maps = rGroup->zebra_maps;
- extractCtrl.flagShowRecords = rGroup->flagShowRecords;
- if (rGroup->flagShowRecords)
+ extractCtrl.flagShowRecords = !rGroup->flagRw;
+ if (!rGroup->flagRw)
printf ("File: %s %ld\n", fname, (long) recordOffset);
logInfo.fname = fname;
if (r)
{
/* error occured during extraction ... */
- if (!rGroup->flagShowRecords &&
- records_processed < rGroup->fileVerboseLimit)
+ if (rGroup->flagRw &&
+ records_processed < rGroup->fileVerboseLimit)
{
logf (LOG_WARN, "fail %s %s %ld code = %d", rGroup->recordType,
fname, (long) recordOffset, r);
{
/* the extraction process returned no information - the record
is probably empty - unless flagShowRecords is in use */
- if (rGroup->flagShowRecords)
+ if (!rGroup->flagRw)
return 1;
logf (LOG_WARN, "No keys generated for file %s", fname);
logf (LOG_WARN, " The file is probably empty");
/* new record */
if (deleteFlag)
{
- logf (LOG_LOG, "Cannot delete new record");
+ logf (LOG_LOG, "delete %s %s %ld", rGroup->recordType,
+ fname, (long) recordOffset);
+ logf (LOG_WARN, "cannot delete record above (seems new)");
return 1;
}
if (records_processed < rGroup->fileVerboseLimit)
/*
- * Copyright (C) 1995-1997, Index Data I/S
+ * Copyright (C) 1995-1998, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: index.h,v $
- * Revision 1.55 1997-10-27 14:33:04 adam
+ * Revision 1.56 1998-01-12 15:04:08 adam
+ * The test option (-s) only uses read-lock (and not write lock).
+ *
+ * Revision 1.55 1997/10/27 14:33:04 adam
* Moved towards generic character mapping depending on "structure"
* field in abstract syntax file. Fixed a few memory leaks. Fixed
* bug with negative integers when doing searches with relational
char *recordType;
int flagStoreData;
int flagStoreKeys;
- int flagShowRecords;
+ int flagRw;
int fileVerboseLimit;
data1_handle dh;
BFiles bfs;
void getFnameTmp (char *fname, int no);
-struct dirs_info *dirs_open (Dict dict, const char *rep);
+struct dirs_info *dirs_open (Dict dict, const char *rep, int rw);
struct dirs_info *dirs_fopen (Dict dict, const char *path);
struct dirs_entry *dirs_read (struct dirs_info *p);
struct dirs_entry *dirs_last (struct dirs_info *p);
void repositoryDelete (struct recordGroup *rGroup);
void repositoryShow (struct recordGroup *rGroup);
-void key_open (BFiles bfs, int mem);
+int key_open (BFiles bfs, int mem, int rw);
int key_close (void);
int key_compare (const void *p1, const void *p2);
int key_get_pos (const void *p);
int fileExtract (SYSNO *sysno, const char *fname,
const struct recordGroup *rGroup, int deleteFlag);
-void rec_prstat (void);
-
void zebraIndexLockMsg (const char *str);
void zebraIndexUnlock (void);
void zebraIndexLock (BFiles bfs, int commitNow, const char *rval);
/*
- * Copyright (C) 1994-1995, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: lockidx.c,v $
- * Revision 1.13 1997-09-29 09:08:36 adam
+ * Revision 1.14 1998-01-12 15:04:08 adam
+ * The test option (-s) only uses read-lock (and not write lock).
+ *
+ * Revision 1.13 1997/09/29 09:08:36 adam
* Revised locking system to be thread safe for the server.
*
* Revision 1.12 1997/09/25 14:54:43 adam
}
else if (*buf == 'w')
{
- logf (LOG_WARN, "your index may be inconsistent");
+ logf (LOG_WARN,
+ "The lock file indicates that your index is");
+ logf (LOG_WARN, "inconsistent. Perhaps the indexer");
+ logf (LOG_WARN, "terminated abnormally in the previous");
+ logf (LOG_WARN, "run. You can try to proceed by");
+ logf (LOG_WARN, "deleting the file %s", path);
exit (1);
}
else if (*buf == 'c')
/*
- * Copyright (C) 1994-1997, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: main.c,v $
- * Revision 1.53 1997-11-18 10:05:08 adam
+ * Revision 1.54 1998-01-12 15:04:08 adam
+ * The test option (-s) only uses read-lock (and not write lock).
+ *
+ * Revision 1.53 1997/11/18 10:05:08 adam
* Changed character map facility so that admin can specify character
* mapping files for each register type, w, p, etc.
*
#include <data1.h>
#include "index.h"
+#include "recindex.h"
char *prog;
-size_t mem_max = 0;
Res common_resource = 0;
-static void abort_func (int level, const char *msg, void *info)
-{
- if (level & LOG_FATAL)
- abort ();
-}
-
int main (int argc, char **argv)
{
int ret;
char *configName = NULL;
int nsections;
int disableCommit = 0;
+ size_t mem_max = 0;
struct recordGroup rGroupDef;
rGroupDef.recordType = NULL;
rGroupDef.flagStoreData = -1;
rGroupDef.flagStoreKeys = -1;
- rGroupDef.flagShowRecords = 0;
+ rGroupDef.flagRw = 1;
rGroupDef.fileVerboseLimit = 100000;
rGroupDef.zebra_maps = NULL;
rGroupDef.dh = data1_create ();
configName : FNAME_CONFIG);
if (!common_resource)
{
- logf (LOG_FATAL, "cannot open resource `%s'",
+ logf (LOG_FATAL, "cannot configuration file `%s'",
configName);
exit (1);
}
}
else if (!strcmp (arg, "stat") || !strcmp (arg, "status"))
{
+ Records records;
rval = res_get (common_resource, "shadow");
zebraIndexLock (rGroupDef.bfs, 0, rval);
if (rval && *rval)
bf_cache (rGroupDef.bfs, rval);
zebraIndexLockMsg ("r");
}
- rec_prstat ();
+ records = rec_open (rGroupDef.bfs, 0);
+ rec_prstat (records);
+ rec_close (&records);
inv_prstat (rGroupDef.bfs);
}
else
exit (1);
}
}
- else
+ else
{
struct recordGroup rGroup;
log_event_end (abort_func, NULL);
rval = res_get (common_resource, "shadow");
zebraIndexLock (rGroupDef.bfs, 0, rval);
- if (rval && *rval && !disableCommit)
- {
- bf_cache (rGroupDef.bfs, rval);
- zebraIndexLockMsg ("r");
- }
- else
- {
- bf_cache (rGroupDef.bfs, 0);
- zebraIndexLockMsg ("w");
- }
- zebraIndexWait (0);
-
+ if (rGroupDef.flagRw)
+ {
+ if (rval && *rval && !disableCommit)
+ {
+ bf_cache (rGroupDef.bfs, rval);
+ zebraIndexLockMsg ("r");
+ }
+ else
+ {
+ bf_cache (rGroupDef.bfs, 0);
+ zebraIndexLockMsg ("w");
+ }
+ zebraIndexWait (0);
+ }
memcpy (&rGroup, &rGroupDef, sizeof(rGroup));
rGroup.path = arg;
switch (cmd)
{
case 'u':
- key_open (rGroup.bfs, mem_max);
- logf (LOG_LOG, "updating %s", rGroup.path);
- repositoryUpdate (&rGroup);
- nsections = key_close ();
+ if (!key_open (rGroup.bfs, mem_max, rGroup.flagRw))
+ {
+ logf (LOG_LOG, "updating %s", rGroup.path);
+ repositoryUpdate (&rGroup);
+ nsections = key_close ();
+ }
break;
case 'U':
- key_open (rGroup.bfs,mem_max);
- logf (LOG_LOG, "updating (pass 1) %s", rGroup.path);
- repositoryUpdate (&rGroup);
- key_close ();
+ if (!key_open (rGroup.bfs,mem_max, rGroup.flagRw))
+ {
+ logf (LOG_LOG, "updating (pass 1) %s", rGroup.path);
+ repositoryUpdate (&rGroup);
+ key_close ();
+ }
nsections = 0;
break;
case 'd':
- key_open (rGroup.bfs,mem_max);
- logf (LOG_LOG, "deleting %s", rGroup.path);
- repositoryDelete (&rGroup);
- nsections = key_close ();
+ if (!key_open (rGroup.bfs,mem_max, rGroup.flagRw))
+ {
+ logf (LOG_LOG, "deleting %s", rGroup.path);
+ repositoryDelete (&rGroup);
+ nsections = key_close ();
+ }
break;
case 's':
logf (LOG_LOG, "dumping %s", rGroup.path);
else if (ret == 'd')
rGroupDef.databaseName = arg;
else if (ret == 's')
- rGroupDef.flagShowRecords = 1;
+ rGroupDef.flagRw = 0;
else if (ret == 'g')
rGroupDef.groupName = arg;
else if (ret == 'f')
else if (ret == 'n')
disableCommit = 1;
else
- {
- logf (LOG_FATAL, "unknown option '-%s'", arg);
- exit (1);
- }
+ logf (LOG_WARN, "unknown option '-%s'", arg);
}
if (common_resource)
{
/*
- * Copyright (C) 1994-1997, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: recindex.c,v $
- * Revision 1.19 1997-09-17 12:19:16 adam
+ * Revision 1.20 1998-01-12 15:04:08 adam
+ * The test option (-s) only uses read-lock (and not write lock).
+ *
+ * Revision 1.19 1997/09/17 12:19:16 adam
* Zebra version corresponds to YAZ version 1.4.
* Changed Zebra server so that it doesn't depend on global common_resource.
*
{
logf (LOG_FATAL|LOG_ERRNO, "read in %s at pos %ld",
p->index_fname, (long) pos);
- abort ();
exit (1);
}
return r;
{
logf (LOG_FATAL|LOG_ERRNO, "read in %s at free block %d",
p->data_fname[dst_type], block_free);
+ exit (1);
}
}
else
/*
- * Copyright (C) 1994-1995, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: recindex.h,v $
- * Revision 1.11 1997-09-17 12:19:16 adam
+ * Revision 1.12 1998-01-12 15:04:08 adam
+ * The test option (-s) only uses read-lock (and not write lock).
+ *
+ * Revision 1.11 1997/09/17 12:19:16 adam
* Zebra version corresponds to YAZ version 1.4.
* Changed Zebra server so that it doesn't depend on global common_resource.
*
void rec_close (Records *p);
Records rec_open (BFiles bfs, int rw);
char *rec_strdup (const char *s, size_t *len);
+void rec_prstat (Records p);
enum {
recInfo_fileType,
/*
- * Copyright (C) 1994-1996, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: recstat.c,v $
- * Revision 1.5 1997-09-17 12:19:17 adam
+ * Revision 1.6 1998-01-12 15:04:08 adam
+ * The test option (-s) only uses read-lock (and not write lock).
+ *
+ * Revision 1.5 1997/09/17 12:19:17 adam
* Zebra version corresponds to YAZ version 1.4.
* Changed Zebra server so that it doesn't depend on global common_resource.
*
#endif
#include "recindxp.h"
-void rec_prstat (BFiles bfs)
+void rec_prstat (Records records)
{
- Records records = rec_open (bfs, 0);
int i;
int total_bytes = 0;
records->head.total_bytes);
logf (LOG_LOG,
"Total size with overhead %8d", total_bytes);
- rec_close (&records);
}
/*
- * Copyright (C) 1994-1997, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: trav.c,v $
- * Revision 1.32 1997-09-25 14:56:51 adam
+ * Revision 1.33 1998-01-12 15:04:08 adam
+ * The test option (-s) only uses read-lock (and not write lock).
+ *
+ * Revision 1.32 1997/09/25 14:56:51 adam
* Windows NT interface code to the stat call.
*
* Revision 1.31 1997/09/17 12:19:17 adam
Dict dict;
struct dirs_info *di;
- if (!(dict = dict_open (rGroup->bfs, FMATCH_DICT, 50, 1)))
+ if (!(dict = dict_open (rGroup->bfs, FMATCH_DICT, 50, 0)))
{
logf (LOG_FATAL, "dict_open fail of %s", FMATCH_DICT);
- exit (1);
+ return;
}
assert (rGroup->path);
src[++src_len] = '\0';
}
- di = dirs_open (dict, src);
+ di = dirs_open (dict, src, rGroup->flagRw);
while ( (dst = dirs_read (di)) )
logf (LOG_LOG, "%s", dst->path);
src[src_len] = '/';
src[++src_len] = '\0';
}
- di = dirs_open (dict, src);
+ di = dirs_open (dict, src, rGroup->flagRw);
*dst = '\0';
fileUpdateR (di, dirs_read (di), src, dst, rGroup);
dirs_free (&di);
}
else
{
- logf (LOG_WARN, "Cannot handle file %s", src);
+ logf (LOG_WARN, "Ignoring path %s", src);
}
}
else if (S_ISDIR(sbuf.st_mode))
repositoryExtractR (deleteFlag, src, rGroup);
else
- logf (LOG_WARN, "Cannot handle file %s", src);
+ logf (LOG_WARN, "Ignoring path %s", src);
}
static void repositoryExtractG (int deleteFlag, struct recordGroup *rGroup)
if (rGroup->recordId && !strcmp (rGroup->recordId, "file"))
{
Dict dict;
- if (!(dict = dict_open (rGroup->bfs, FMATCH_DICT, 50, 1)))
+ if (!(dict = dict_open (rGroup->bfs, FMATCH_DICT, 50, rGroup->flagRw)))
{
logf (LOG_FATAL, "dict_open fail of %s", FMATCH_DICT);
- exit (1);
+ return ;
}
if (*rGroup->path == '\0' || !strcmp(rGroup->path, "-"))
{
/*
- * Copyright (C) 1994-1997, Index Data I/S
+ * Copyright (C) 1994-1998, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: trunc.c,v $
- * Revision 1.8 1997-10-31 12:34:27 adam
+ * Revision 1.9 1998-01-12 15:04:09 adam
+ * The test option (-s) only uses read-lock (and not write lock).
+ *
+ * Revision 1.8 1997/10/31 12:34:27 adam
* Bug fix: memory leak.
*
* Revision 1.7 1997/09/29 09:07:29 adam
qsort (isam_p, no, sizeof(*isam_p), isamc_trunc_cmp);
}
else
- logf (LOG_FATAL, "Neither isam nor isamc set in rset_trunc");
+ {
+ logf (LOG_WARN, "Neither isam nor isamc set in rset_trunc");
+ return rset_create (rset_kind_null, NULL);
+ }
return rset_trunc_r (zi, isam_p, 0, no, 100);
}
/*
- * Copyright (C) 1995-1997, Index Data I/S
+ * Copyright (C) 1995-1998, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.c,v $
- * Revision 1.52 1997-11-18 10:05:08 adam
+ * Revision 1.53 1998-01-12 15:04:09 adam
+ * The test option (-s) only uses read-lock (and not write lock).
+ *
+ * Revision 1.52 1997/11/18 10:05:08 adam
* Changed character map facility so that admin can specify character
* mapping files for each register type, w, p, etc.
*
logf (LOG_LOG, "Reading resources from %s", sob->configname);
if (!(zi->res = res_open (sob->configname)))
{
- logf (LOG_FATAL, "Cannot open resource `%s'", sob->configname);
- exit (1);
+ logf (LOG_FATAL, "Failed to read resources `%s'", sob->configname);
+ r->errcode = 1;
+ return r;
}
zebra_server_lock_init (zi);
zi->dh = data1_create ();
if (!(rt = recType_byName (file_type, subType)))
{
- logf (LOG_FATAL|LOG_ERRNO, "Retrieve: Cannot handle type %s",
- file_type);
- exit (1);
+ logf (LOG_WARN, "Retrieve: Cannot handle type %s", file_type);
+ return 14;
}
logf (LOG_DEBUG, "retrieve localno=%d score=%d", sysno, score);
retrieveCtrl.fh = &fc;