X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=server%2Fseshigh.c;h=294651cdaad792e95aff907a6bb2cd3243f457c4;hb=29818ed78e32998641adcf5f23d3b854355918b5;hp=a062b3dd07f1b221ed2a11b681da5675fd0db869;hpb=d09e17f371431d3397588e6b749219608d37766a;p=yaz-moved-to-github.git diff --git a/server/seshigh.c b/server/seshigh.c index a062b3d..294651c 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -4,7 +4,19 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: seshigh.c,v $ - * Revision 1.46 1995-08-29 11:17:58 quinn + * Revision 1.50 1995-10-25 16:58:32 quinn + * Simple. + * + * Revision 1.49 1995/10/16 13:51:53 quinn + * Changes to provide Especs to the backend. + * + * Revision 1.48 1995/10/06 08:51:20 quinn + * Added Write-buffer. + * + * Revision 1.47 1995/08/29 14:24:16 quinn + * Added second half of close-handshake + * + * Revision 1.46 1995/08/29 11:17:58 quinn * Added code to receive close * * Revision 1.45 1995/08/21 09:11:00 quinn @@ -17,8 +29,6 @@ * Updated External * * Revision 1.42 1995/08/15 11:16:50 quinn - * CV:e ---------------------------------------------------------------------- - * CV:e ---------------------------------------------------------------------- * * Revision 1.41 1995/08/02 10:23:06 quinn * Smallish @@ -205,6 +215,7 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, static Z_APDU *process_presentRequest(association *assoc, request *reqb, int *fd); static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd); +static void process_close(association *assoc, request *reqb); static FILE *apduf = 0; /* for use in static mode */ static statserv_options_block *control_block = 0; @@ -391,8 +402,9 @@ void ir_session(IOCHAN h, int event) odr_setbuf(assoc->decode, assoc->input_buffer, res, 0); if (!z_APDU(assoc->decode, &req->request, 0)) { - logf(LOG_LOG, "ODR error on incoming PDU: %s", - odr_errlist[odr_geterror(assoc->decode)]); + logf(LOG_LOG, "ODR error on incoming PDU: %s [near byte %d] ", + odr_errlist[odr_geterror(assoc->decode)], + odr_offset(assoc->decode)); logf(LOG_LOG, "PDU dump:"); odr_dumpBER(log_file(), assoc->input_buffer, res); do_close(assoc, Z_Close_protocolError, "Malformed package"); @@ -469,6 +481,8 @@ static int process_request(association *assoc) res = process_presentRequest(assoc, req, &fd); break; case Z_APDU_scanRequest: res = process_scanRequest(assoc, req, &fd); break; + case Z_APDU_close: + process_close(assoc, req); return 0; default: logf(LOG_WARN, "Bad APDU received"); return -1; @@ -578,7 +592,7 @@ static int process_response(association *assoc, request *req, Z_APDU *res) /* * Handle init request. - * At the moment, we don't check the protocol version or the options + * At the moment, we don't check the options * anywhere else in the code - we just try not to do anything that would * break a naive client. We'll toss 'em into the association block when * we need them there. @@ -800,7 +814,7 @@ static Z_DiagRecs *diagrecs(oid_proto proto, int error, char *addinfo) #define MAX_RECORDS 256 static Z_Records *pack_records(association *a, char *setname, int start, - int *num, Z_ElementSetNames *esn, + int *num, Z_RecordComposition *comp, int *next, int *pres, oid_value format) { int recno, total_length = 0, toget = *num; @@ -841,6 +855,7 @@ static Z_Records *pack_records(association *a, char *setname, int start, } freq.setname = setname; freq.number = recno; + freq.comp = comp; freq.format = format; freq.stream = a->encode; if (!(fres = bend_fetch(a->backend, &freq, 0))) @@ -1029,24 +1044,25 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, else { static int toget; - Z_ElementSetNames *setnames; + Z_RecordComposition comp; static int presst = 0; resp.records = 0; resp.resultCount = &bsrt->hits; + comp.which = Z_RecordComp_simple; /* how many records does the user agent want, then? */ if (bsrt->hits <= *req->smallSetUpperBound) { toget = bsrt->hits; - setnames = req->smallSetElementSetNames; + comp.u.simple = req->smallSetElementSetNames; } else if (bsrt->hits < *req->largeSetLowerBound) { toget = *req->mediumSetPresentNumber; if (toget > bsrt->hits) toget = bsrt->hits; - setnames = req->mediumSetElementSetNames; + comp.u.simple = req->mediumSetElementSetNames; } else toget = 0; @@ -1062,7 +1078,7 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb, else form = prefformat->value; resp.records = pack_records(assoc, req->resultSetName, 1, - &toget, setnames, &next, &presst, form); + &toget, &comp, &next, &presst, form); if (!resp.records) return 0; resp.numberOfRecordsReturned = &toget; @@ -1126,7 +1142,8 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb, form = prefformat->value; num = *req->numberOfRecordsRequested; resp.records = pack_records(assoc, req->resultSetId, - *req->resultSetStartPoint, &num, 0, &next, &presst, form); + *req->resultSetStartPoint, &num, req->recordComposition, &next, + &presst, form); if (!resp.records) return 0; resp.numberOfRecordsReturned = # @@ -1239,3 +1256,28 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd) return &apdu; } + +static void process_close(association *assoc, request *reqb) +{ + Z_Close *req = reqb->request->u.close; + static char *reasons[] = + { + "finished", + "shutdown", + "systemProblem", + "costLimit", + "resources", + "securityViolation", + "protocolError", + "lackOfActivity", + "peerAbort", + "unspecified" + }; + + logf(LOG_LOG, "Got close, reason %s, message %s", + reasons[*req->closeReason], req->diagnosticInformation ? + req->diagnosticInformation : "NULL"); + if (assoc->version < 3) /* to make do_force respond with close */ + assoc->version = 3; + do_close(assoc, Z_Close_finished, "Association terminated by client"); +}