/*
- * Copyright (C) 1994-1995, Index Data I/S
+ * Copyright (C) 1994-1996, Index Data I/S
* All rights reserved.
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: trav.c,v $
- * Revision 1.23 1996-04-12 07:02:25 adam
+ * Revision 1.29 1997-02-12 20:39:47 adam
+ * Implemented options -f <n> that limits the log to the first <n>
+ * records.
+ * Changed some log messages also.
+ *
+ * Revision 1.28 1996/11/01 08:58:44 adam
+ * Interface to isamc system now includes update and delete.
+ *
+ * Revision 1.27 1996/10/29 14:06:56 adam
+ * Include zebrautl.h instead of alexutil.h.
+ *
+ * Revision 1.26 1996/06/04 10:19:01 adam
+ * Minor changes - removed include of ctype.h.
+ *
+ * Revision 1.25 1996/05/01 13:46:37 adam
+ * First work on multiple records in one file.
+ * New option, -offset, to the "unread" command in the filter module.
+ *
+ * Revision 1.24 1996/04/26 10:00:23 adam
+ * Added option -V to zebraidx to display version information.
+ * Removed stupid warnings from file update.
+ *
+ * Revision 1.23 1996/04/12 07:02:25 adam
* File update of single files.
*
* Revision 1.22 1996/04/09 06:50:50 adam
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
-#include <ctype.h>
#include <time.h>
-#include <alexutil.h>
#include "index.h"
static int repComp (const char *a, const char *b, size_t len)
e = dir_open (rep);
if (!e)
return;
- logf (LOG_LOG, "Dir: %s", rep);
+ logf (LOG_LOG, "dir %s", rep);
if (rep[rep_len-1] != '/')
rep[rep_len] = '/';
else
}
-static void stdinExtractR (int deleteFlag, struct recordGroup *rGroup)
-{
- char tmppath[1024];
-
- logf (LOG_LOG, "stdinExtractR");
- while (scanf ("%s", tmppath) == 1)
- fileExtract (NULL, tmppath, rGroup, deleteFlag);
-}
-
static void fileDeleteR (struct dirs_info *di, struct dirs_entry *dst,
const char *base, char *src,
struct recordGroup *rGroup)
sprintf (tmppath, "%s%s", base, src);
e_src = dir_open (tmppath);
- logf (LOG_LOG, "Dir: %s", tmppath);
+ logf (LOG_LOG, "dir %s", tmppath);
#if 0
if (!dst || repComp (dst->path, src, src_len))
{
dirs_add (di, src, dst->sysno, e_src[i_src].mtime);
}
- logf (LOG_LOG, "old: %s", ctime (&dst->mtime));
- logf (LOG_LOG, "new: %s", ctime (&e_src[i_src].mtime));
+ logf (LOG_DEBUG, "old: %s", ctime (&dst->mtime));
+ logf (LOG_DEBUG, "new: %s", ctime (&e_src[i_src].mtime));
}
dst = dirs_read (di);
break;
rGroup->recordId = res_get (common_resource, resStr);
}
-
void repositoryShow (struct recordGroup *rGroup)
{
char src[1024];
struct dirs_entry *e_dst;
di = dirs_fopen (dict, src);
- logf (LOG_WARN, "Handle file %s", src);
e_dst = dirs_read (di);
if (e_dst)
{
- logf (LOG_WARN, "Update Handle file %s", src);
if (sbuf.st_mtime > e_dst->mtime)
if (fileExtract (&e_dst->sysno, src, rGroup, 0))
dirs_add (di, src, e_dst->sysno, sbuf.st_mtime);
else
{
SYSNO sysno = 0;
- logf (LOG_WARN, "New Handle file %s", src);
if (fileExtract (&sysno, src, rGroup, 0))
dirs_add (di, src, sysno, sbuf.st_mtime);
}
}
}
+
+static void repositoryExtract (int deleteFlag, struct recordGroup *rGroup,
+ const char *path)
+{
+ struct stat sbuf;
+ char src[1024];
+
+ assert (path);
+ strcpy (src, path);
+
+ stat (src, &sbuf);
+ if (S_ISREG(sbuf.st_mode))
+ fileExtract (NULL, src, rGroup, deleteFlag);
+ else if (S_ISDIR(sbuf.st_mode))
+ repositoryExtractR (deleteFlag, src, rGroup);
+ else
+ logf (LOG_WARN, "Cannot handle file %s", src);
+}
+
+static void repositoryExtractG (int deleteFlag, struct recordGroup *rGroup)
+{
+ if (*rGroup->path == '\0' || !strcmp(rGroup->path, "-"))
+ {
+ char src[1024];
+
+ while (scanf ("%s", src) == 1)
+ repositoryExtract (deleteFlag, rGroup, src);
+ }
+ else
+ repositoryExtract (deleteFlag, rGroup, rGroup->path);
+}
+
void repositoryUpdate (struct recordGroup *rGroup)
{
groupRes (rGroup);
dict_close (dict);
}
else
- {
- char src[1024];
-
- strcpy (src, rGroup->path);
- if (*src == '\0' || !strcmp (src, "-"))
- stdinExtractR (0, rGroup);
- else
- repositoryExtractR (0, src, rGroup);
- }
+ repositoryExtractG (0, rGroup);
}
void repositoryDelete (struct recordGroup *rGroup)
{
- char src[256];
-
- assert (rGroup->path);
- groupRes (rGroup);
- strcpy (src, rGroup->path);
- if (*src == '\0' || !strcmp(src, "-"))
- stdinExtractR (1, rGroup);
- else
- repositoryExtractR (1, src, rGroup);
+ repositoryExtractG (1, rGroup);
}