From 26f25a4dd83618b5230956c6fb37bdda473ce501 Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Thu, 30 Mar 1995 12:18:17 +0000 Subject: [PATCH] Fixed bug. --- server/seshigh.c | 102 ++++++++++++++++++++++++++++++----------------------- server/statserv.c | 22 +++++++++--- 2 files changed, 76 insertions(+), 48 deletions(-) diff --git a/server/seshigh.c b/server/seshigh.c index cb815fb..ef26b1e 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: seshigh.c,v $ - * Revision 1.13 1995-03-30 09:09:24 quinn + * Revision 1.14 1995-03-30 12:18:17 quinn + * Fixed bug. + * + * Revision 1.13 1995/03/30 09:09:24 quinn * Added state-handle and some support for asynchronous activities. * * Revision 1.12 1995/03/29 15:40:16 quinn @@ -250,7 +253,7 @@ static int process_initRequest(IOCHAN client, Z_InitRequest *req) resp.result = &result; resp.implementationId = "YAZ"; resp.implementationName = "Index Data/YAZ Generic Frontend Server"; - resp.implementationVersion = "$Revision: 1.13 $"; + resp.implementationVersion = "$Revision: 1.14 $"; resp.userInformationField = 0; if (!z_APDU(assoc->encode, &apdup, 0)) { @@ -442,6 +445,7 @@ static int process_searchRequest(IOCHAN client, Z_SearchRequest *req) bend_searchresult *bsrt; oident *oent; int next = 0; + static int none = Z_RES_NONE; fprintf(stderr, "Got SearchRequest.\n"); apdup = &apdu; @@ -457,7 +461,15 @@ static int process_searchRequest(IOCHAN client, Z_SearchRequest *req) if (!(oent = oid_getentbyoid(q->attributeSetId)) || oent->class != CLASS_ATTSET || oent->value != VAL_BIB1) + { resp.records = diagrec(assoc->proto, 121, 0); + resp.resultCount = &nulint; + resp.numberOfRecordsReturned = &nulint; + resp.nextResultSetPosition = &nulint; + resp.searchStatus = &none; + resp.resultSetStatus = 0; + resp.presentStatus = 0; + } } if (!resp.records) { @@ -474,57 +486,59 @@ static int process_searchRequest(IOCHAN client, Z_SearchRequest *req) if (!(bsrt = bend_search(assoc->backend, &bsrq, 0))) return -1; else if (bsrt->errcode) + { + resp.records = diagrec(assoc->proto, bsrt->errcode, bsrt->errstring); + resp.resultCount = &nulint; + resp.numberOfRecordsReturned = &nulint; + resp.nextResultSetPosition = &nulint; + resp.searchStatus = &nulint; + resp.resultSetStatus = &none; + resp.presentStatus = 0; + } else + { resp.records = 0; - resp.resultCount = &bsrt->hits; + resp.resultCount = &bsrt->hits; - /* how many records does the user agent want, then? */ - if (bsrt->hits <= *req->smallSetUpperBound) - { - toget = bsrt->hits; - setnames = req->smallSetElementSetNames; - } - else if (bsrt->hits < *req->largeSetLowerBound) - { - toget = *req->mediumSetPresentNumber; - setnames = req->mediumSetElementSetNames; - } - else - toget = 0; + /* how many records does the user agent want, then? */ + if (bsrt->hits <= *req->smallSetUpperBound) + { + toget = bsrt->hits; + setnames = req->smallSetElementSetNames; + } + else if (bsrt->hits < *req->largeSetLowerBound) + { + toget = *req->mediumSetPresentNumber; + setnames = req->mediumSetElementSetNames; + } + else + toget = 0; - if (toget) - { - resp.records = pack_records(assoc, req->resultSetName, 1, &toget, - setnames, &next, &presst); - if (!resp.records) - return -1; - resp.numberOfRecordsReturned = &toget; - resp.nextResultSetPosition = &next; - resp.searchStatus = &sr; - resp.resultSetStatus = &sr; - resp.presentStatus = &presst; - } - else - { - resp.records = 0; - resp.numberOfRecordsReturned = &nulint; - resp.nextResultSetPosition = &nulint; - resp.searchStatus = &sr; - resp.resultSetStatus = &sr; - resp.presentStatus = 0; + if (toget && !resp.records) + { + resp.records = pack_records(assoc, req->resultSetName, 1, + &toget, setnames, &next, &presst); + if (!resp.records) + return -1; + resp.numberOfRecordsReturned = &toget; + resp.nextResultSetPosition = &next; + resp.searchStatus = &sr; + resp.resultSetStatus = 0; + resp.presentStatus = &presst; + } + else + { + resp.numberOfRecordsReturned = &nulint; + resp.nextResultSetPosition = &next; + resp.searchStatus = &sr; + resp.resultSetStatus = 0; + resp.presentStatus = 0; + } } } - else - { - resp.resultCount = &nulint; - resp.numberOfRecordsReturned = &nulint; - resp.nextResultSetPosition = &nulint; - resp.searchStatus = &nulint; - resp.resultSetStatus = 0; - } if (!z_APDU(assoc->encode, &apdup, 0)) { diff --git a/server/statserv.c b/server/statserv.c index 84190dd..69de493 100644 --- a/server/statserv.c +++ b/server/statserv.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: statserv.c,v $ - * Revision 1.10 1995-03-29 15:40:16 quinn + * Revision 1.11 1995-03-30 12:18:17 quinn + * Fixed bug. + * + * Revision 1.10 1995/03/29 15:40:16 quinn * Ongoing work. Statserv is now dynamic by default * * Revision 1.9 1995/03/27 08:34:30 quinn @@ -58,6 +61,7 @@ #include #include #include +#include static char *me = ""; static int dynamic = 1; /* fork on incoming connection */ @@ -254,10 +258,12 @@ int statserv_main(int argc, char **argv) { int ret, listeners = 0; char *arg; - int protocol = CS_Z3950;; + int protocol = CS_Z3950; + char *logfile = 0; + int loglevel = LOG_DEFAULT_LEVEL; me = argv[0]; - while ((ret = options("szSl:", argv, argc, &arg)) != -2) + while ((ret = options("szSl:v:", argv, argc, &arg)) != -2) switch (ret) { case 0: @@ -267,8 +273,16 @@ int statserv_main(int argc, char **argv) case 'z': protocol = CS_Z3950; break; case 's': protocol = CS_SR; break; case 'S': dynamic = 0; break; + case 'l': + logfile = arg; + log_init(loglevel, me, logfile); + break; + case 'v': + loglevel = log_mask_str(arg); + log_init(loglevel, me, logfile); + break; default: - fprintf(stderr, "Usage: %s [ -zsS ... ]\n", me); + fprintf(stderr, "Usage: %s [ -v -l -zsS ... ]\n", me); exit(1); } if (dynamic) -- 1.7.10.4