* Sebastian Hammer, Adam Dickmeiss
*
* $Log: extract.c,v $
- * Revision 1.88 1998-10-16 08:14:29 adam
+ * Revision 1.89 1998-10-28 10:54:38 adam
+ * SDRKit integration.
+ *
+ * Revision 1.88 1998/10/16 08:14:29 adam
* Updated record control system.
*
* Revision 1.87 1998/10/15 13:10:33 adam
#include "zinfo.h"
+#ifndef ZEBRASDR
+#define ZEBRASDR 0
+#endif
+
+#if ZEBRASDR
+#include "zebrasdr.h"
+#endif
+
static Dict matchDict;
static Records records = NULL;
}
struct file_read_info {
- off_t file_max;
- off_t file_offset;
- off_t file_moffset;
+ off_t file_max; /* maximum offset so far */
+ off_t file_offset; /* current offset */
+ off_t file_moffset; /* offset of rec/rec boundary */
int file_more;
int fd;
+ char *sdrbuf;
+ int sdrmax;
};
static struct file_read_info *file_read_start (int fd)
fi->fd = fd;
fi->file_max = 0;
fi->file_moffset = 0;
+ fi->sdrbuf = 0;
+ fi->sdrmax = 0;
return fi;
}
{
struct file_read_info *p = handle;
p->file_offset = offset;
+ if (p->sdrbuf)
+ return offset;
return lseek (p->fd, offset, SEEK_SET);
}
struct file_read_info *p = handle;
int fd = p->fd;
int r;
- r = read (fd, buf, count);
+ if (p->sdrbuf)
+ {
+ r = count;
+ if (r > p->sdrmax - p->file_offset)
+ r = p->sdrmax - p->file_offset;
+ if (r)
+ memcpy (buf, p->sdrbuf + p->file_offset, r);
+ }
+ else
+ r = read (fd, buf, count);
if (r > 0)
{
p->file_offset += r;
struct file_read_info *p = handle;
p->file_offset = p->file_moffset;
- if (p->file_moffset)
+ if (!p->sdrbuf && p->file_moffset)
lseek (p->fd, p->file_moffset, SEEK_SET);
p->file_more = 0;
}
if (rGroup->flagStoreKeys == -1)
rGroup->flagStoreKeys = 0;
+#if ZEBRASDR
+ if (1)
+ {
+ ZebraSdrHandle h;
+ char xname[128], *xp;
+
+ strncpy (xname, fname, 127);
+ if ((xp = strchr (xname, '.')))
+ *xp = '\0';
+
+ h = zebraSdr_open (xname);
+ if (!h)
+ {
+ logf (LOG_WARN, "sdr open %s", xname);
+ return 0;
+ }
+ for (;;)
+ {
+ unsigned char *buf;
+ char sdr_name[128];
+ int r, segmentno;
+
+ segmentno = zebraSdr_segment (h, 0);
+ sprintf (sdr_name, "%%%s.%d", xname, segmentno);
+ logf (LOG_LOG, "SDR: %s", sdr_name);
+
+#if 1
+ if (segmentno > 20)
+ break;
+#endif
+ r = zebraSdr_read (h, &buf);
+
+ if (!r)
+ break;
+
+ fi = file_read_start (0);
+ fi->sdrbuf = buf;
+ fi->sdrmax = r;
+ do
+ {
+ file_begin (fi);
+ r = recordExtract (sysno, sdr_name, rGroup, deleteFlag, fi,
+ recType, subType);
+ } while (r && !sysno && fi->file_more);
+ file_read_stop (fi);
+ free (buf);
+ }
+ zebraSdr_close (h);
+ return 1;
+ }
+#endif
if (sysno && deleteFlag)
fd = -1;
else
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: main.c,v $
- * Revision 1.59 1998-10-16 08:14:32 adam
+ * Revision 1.60 1998-10-28 10:54:39 adam
+ * SDRKit integration.
+ *
+ * Revision 1.59 1998/10/16 08:14:32 adam
* Updated record control system.
*
* Revision 1.58 1998/06/08 14:43:13 adam
#include "index.h"
#include "recindex.h"
+#ifndef ZEBRASDR
+#define ZEBRASDR 0
+#endif
+
+#if ZEBRASDR
+#include "zebrasdr.h"
+#endif
+
char *prog;
Res common_resource = 0;
nmem_init ();
+#if ZEBRASDR
+ zebraSdr_std ();
+#endif
rGroupDef.groupName = NULL;
rGroupDef.databaseName = NULL;
rGroupDef.path = NULL;
);
exit (1);
}
- while ((ret = options ("sVt:c:g:d:m:v:nf:", argv, argc, &arg)) != -2)
+ while ((ret = options ("sVt:c:g:d:m:v:nf:l:", argv, argc, &arg)) != -2)
{
if (ret == 0)
{
fprintf (stderr, "Zebra %s %s\n", ZEBRAVER, ZEBRADATE);
}
else if (ret == 'v')
- log_init (log_mask_str(arg), prog, NULL);
+ log_init_level (log_mask_str(arg));
+ else if (ret == 'l')
+ log_init_file (arg);
else if (ret == 'm')
mem_max = 1024*1024*atoi(arg);
else if (ret == 'd')
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: retrieve.c,v $
- * Revision 1.2 1998-10-16 08:14:33 adam
+ * Revision 1.3 1998-10-28 10:54:40 adam
+ * SDRKit integration.
+ *
+ * Revision 1.2 1998/10/16 08:14:33 adam
* Updated record control system.
*
* Revision 1.1 1998/03/05 08:45:13 adam
#include <recctrl.h>
#include "zserver.h"
+#ifndef ZEBRASDR
+#define ZEBRASDR 0
+#endif
+
+#if ZEBRASDR
+#include "zebrasdr.h"
+#endif
+
struct fetch_control {
int record_offset;
int record_int_pos;
int l = fc->record_int_len - fc->record_int_pos;
if (l <= 0)
return 0;
- l = (l < count) ? l : count;
+ l = (l < (int) count) ? l : count;
memcpy (buf, fc->record_int_buf + fc->record_int_pos, l);
fc->record_int_pos += l;
return l;
fc.record_int_pos = 0;
logf (LOG_DEBUG, "Internal retrieve. %d bytes", fc.record_int_len);
}
- else
+#if ZEBRASDR
+ else if (*fname == '%')
+ {
+ ZebraSdrHandle h;
+ int segment = 0, r;
+ char *cp, xname[128];
+ unsigned char *buf;
+
+ logf (LOG_DEBUG, "SDR");
+ strcpy (xname, fname+1);
+ if ((cp = strrchr (xname, '.')))
+ {
+ *cp++ = 0;
+ segment = atoi(cp);
+ }
+ h = zebraSdr_open (xname);
+ if (!h)
+ {
+ logf (LOG_WARN, "sdr open %s", xname);
+ return 0;
+ }
+ if (zebraSdr_segment (h, &segment) < 0)
+ {
+ logf (LOG_WARN, "zebraSdr_segment fail segment=%d",
+ segment);
+ rec_rm (&rec);
+ return 14;
+ }
+ r = zebraSdr_read (h, &buf);
+ if (r < 1)
+ {
+ logf (LOG_WARN, "zebraSdr_read fail segment=%d",
+ segment);
+ rec_rm (&rec);
+ return 14;
+ }
+ zebraSdr_close (h);
+
+ fc.record_int_len = recordAttr->recordSize;
+ fc.record_int_buf = buf + recordAttr->recordOffset;
+ fc.record_int_pos = 0;
+
+ logf (LOG_LOG, "segment = %d len=%d off=%d",
+ segment,
+ recordAttr->recordSize,
+ recordAttr->recordOffset);
+ if (fc.record_int_len > 180)
+ {
+ logf (LOG_LOG, "%0.70s", fc.record_int_buf);
+ logf (LOG_LOG, "%0.70s", fc.record_int_buf +
+ (fc.record_int_len - 70));
+ }
+ else
+ logf (LOG_LOG, "%0.*s",
+ fc.record_int_len, fc.record_int_buf);
+
+ /* the following two lines makes rec_rm delete buf */
+ rec->size[recInfo_storeData] = r;
+ rec->info[recInfo_storeData] = buf;
+
+ retrieveCtrl.readf = record_int_read;
+ retrieveCtrl.seekf = record_int_seek;
+ retrieveCtrl.tellf = record_int_tell;
+ }
+#endif
+ else
{
if ((fc.fd = open (fname, O_BINARY|O_RDONLY)) == -1)
{
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.c,v $
- * Revision 1.65 1998-10-18 07:54:54 adam
+ * Revision 1.66 1998-10-28 10:54:41 adam
+ * SDRKit integration.
+ *
+ * Revision 1.65 1998/10/18 07:54:54 adam
* Additional info added for diagnostics 114 (Unsupported use attribute) and
* 121 (Unsupported attribute set).
*
#include "zserver.h"
+#ifndef ZEBRASDR
+#define ZEBRASDR 0
+#endif
+#if ZEBRASDR
+#include "zebrasdr.h"
+#endif
+
static int bend_sort (void *handle, bend_sort_rr *rr);
bend_initresult *bend_init (bend_initrequest *q)
#endif
statserv_setcontrol (sob);
+#if ZEBRASDR
+ zebraSdr_std ();
+#endif
return statserv_main (argc, argv);
}
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "include" /I "..\yaz\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "WINDOWS" /FR /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /GX /Zi /Od /I "include" /I "..\yaz\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "WINDOWS" /FR /YX /FD /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo