From: Adam Dickmeiss Date: Mon, 27 Nov 1995 13:58:53 +0000 (+0000) Subject: New option -t. storeStore data implemented in server. X-Git-Tag: ZEBRA.1.0~660 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=493237735ce44d9216b870542b90a3c5f393a586;p=idzebra-moved-to-github.git New option -t. storeStore data implemented in server. --- diff --git a/index/Makefile b/index/Makefile index c7c6dde..44e5e2b 100644 --- a/index/Makefile +++ b/index/Makefile @@ -1,14 +1,14 @@ # Copyright (C) 1995, Index Data I/S # All rights reserved. # Sebastian Hammer, Adam Dickmeiss -# $Id: Makefile,v 1.23 1995-11-27 09:56:18 adam Exp $ +# $Id: Makefile,v 1.24 1995-11-27 13:58:53 adam Exp $ SHELL=/bin/sh RANLIB=ranlib -YAZLIB=-lyaz -#YAZINC=-I../../yaz/include -OSILIB=../../xtimosi/src/libmosi.a -lrfc +YAZLIB=../../yaz/lib/libyaz.a +YAZINC=-I../../yaz/include +OSILIB=../../xtimosi/src/libmosi.a ../../yaz/lib/librfc.a #NETLIB=-lnsl -lsocket INCLUDE=-I../include $(YAZINC) diff --git a/index/index.h b/index/index.h index ae05ece..1894cb5 100644 --- a/index/index.h +++ b/index/index.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: index.h,v $ - * Revision 1.27 1995-11-25 10:24:06 adam + * Revision 1.28 1995-11-27 13:58:53 adam + * New option -t. storeStore data implemented in server. + * + * Revision 1.27 1995/11/25 10:24:06 adam * More record fields - they are enumerated now. * New options: flagStoreData flagStoreKey. * @@ -125,6 +128,7 @@ struct recordGroup { char *databaseName; char *path; char *fileMatch; + char *fileType; int flagStoreData; int flagStoreKeys; }; diff --git a/index/main.c b/index/main.c index ae3095e..41a9579 100644 --- a/index/main.c +++ b/index/main.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: main.c,v $ - * Revision 1.19 1995-11-25 10:24:06 adam + * Revision 1.20 1995-11-27 13:58:53 adam + * New option -t. storeStore data implemented in server. + * + * Revision 1.19 1995/11/25 10:24:06 adam * More record fields - they are enumerated now. * New options: flagStoreData flagStoreKey. * @@ -95,6 +98,7 @@ int main (int argc, char **argv) rGroup.fileMatch = NULL; rGroup.flagStoreData = -1; rGroup.flagStoreKeys = -1; + rGroup.fileType = NULL; prog = *argv; if (argc < 2) @@ -103,7 +107,7 @@ int main (int argc, char **argv) " [-g group] cmd1 dir1 cmd2 dir2 ...\n"); exit (1); } - while ((ret = options ("c:g:v:m:d:", argv, argc, &arg)) != -2) + while ((ret = options ("t:c:g:v:m:d:", argv, argc, &arg)) != -2) { if (ret == 0) { @@ -175,6 +179,8 @@ int main (int argc, char **argv) } else if (ret == 'c') configName = arg; + else if (ret == 't') + rGroup.fileType = arg; else { logf (LOG_FATAL, "Unknown option '-%s'", arg); diff --git a/index/zserver.c b/index/zserver.c index 74a017c..3251127 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.c,v $ - * Revision 1.26 1995-11-25 10:24:07 adam + * Revision 1.27 1995-11-27 13:58:54 adam + * New option -t. storeStore data implemented in server. + * + * Revision 1.26 1995/11/25 10:24:07 adam * More record fields - they are enumerated now. * New options: flagStoreData flagStoreKey. * @@ -177,11 +180,26 @@ bend_searchresult *bend_search (void *handle, bend_searchrequest *q, int *fd) return &r; } -static int record_read (int fd, char *buf, size_t count) +static int record_ext_read (int fd, char *buf, size_t count) { return read (fd, buf, count); } +static int record_int_pos; +static char *record_int_buf; +static int record_int_len; + +static int record_int_read (int fd, char *buf, size_t count) +{ + int l = record_int_len - record_int_pos; + if (l <= 0) + return 0; + l = (l < count) ? l : count; + memcpy (buf, record_int_buf + record_int_pos, l); + record_int_buf += l; + return l; +} + static int record_fetch (ZServerInfo *zi, int sysno, int score, ODR stream, oid_value input_format, Z_RecordComposition *comp, oid_value *output_format, char **rec_bufp, @@ -203,20 +221,30 @@ static int record_fetch (ZServerInfo *zi, int sysno, int score, ODR stream, exit (1); } logf (LOG_DEBUG, "retrieve localno=%d score=%d", sysno, score); - if ((retrieveCtrl.fd = open (fname, O_RDONLY)) == -1) + if (rec->size[recInfo_storeData] > 0) { - char *msg = "Record doesn't exist"; - logf (LOG_WARN|LOG_ERRNO, "Retrieve: Open record file %s", fname); - *output_format = VAL_SUTRS; - *rec_bufp = msg; - *rec_lenp = strlen (msg); - rec_rm (&rec); - return 0; /* or 14: System error in presenting records */ + retrieveCtrl.readf = record_int_read; + record_int_len = rec->size[recInfo_storeData]; + record_int_buf = rec->info[recInfo_storeData]; + record_int_pos = 0; + } + else + { + if ((retrieveCtrl.fd = open (fname, O_RDONLY)) == -1) + { + char *msg = "Record doesn't exist"; + logf (LOG_WARN|LOG_ERRNO, "Retrieve: Open record file %s", fname); + *output_format = VAL_SUTRS; + *rec_bufp = msg; + *rec_lenp = strlen (msg); + rec_rm (&rec); + return 0; /* or 14: System error in presenting records */ + } + retrieveCtrl.readf = record_ext_read; } retrieveCtrl.localno = sysno; retrieveCtrl.score = score; retrieveCtrl.odr = stream; - retrieveCtrl.readf = record_read; retrieveCtrl.input_format = retrieveCtrl.output_format = input_format; retrieveCtrl.comp = comp; retrieveCtrl.diagnostic = 0;