X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=server%2Fseshigh.c;h=e3555582bd5708a31e3ef028a11efbf2f124d566;hb=944822bc44705a21ec8b9ce44e0765e0fe37f635;hp=2007f3e676f98ec22f23bb40cb594a84a8afa9f7;hpb=79b35f162af8212091fab0ca10b458c262685eaa;p=yaz-moved-to-github.git diff --git a/server/seshigh.c b/server/seshigh.c index 2007f3e..e355558 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -4,7 +4,20 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: seshigh.c,v $ - * Revision 1.17 1995-04-10 10:23:36 quinn + * Revision 1.21 1995-05-02 08:53:19 quinn + * Trying in vain to fix comm with ISODE + * + * Revision 1.20 1995/04/20 15:13:00 quinn + * Cosmetic + * + * Revision 1.19 1995/04/18 08:15:34 quinn + * Added dynamic memory allocation on encoding (whew). Code is now somewhat + * neater. We'll make the same change for decoding one day. + * + * Revision 1.18 1995/04/17 11:28:25 quinn + * Smallish + * + * Revision 1.17 1995/04/10 10:23:36 quinn * Some work to add scan and other things. * * Revision 1.16 1995/03/31 09:18:55 quinn @@ -72,7 +85,7 @@ #include -#define ENCODE_BUFFER_SIZE 10000 +#define MAXRECORDSIZE 1024*1024*5 /* should be configurable, of course */ static int process_apdu(IOCHAN chan); static int process_initRequest(IOCHAN client, Z_InitRequest *req); @@ -85,6 +98,12 @@ extern char *apdufile; static FILE *apduf = 0; /* for use in static mode */ +/* + * Create a new association-handle. + * channel : iochannel for the current line. + * link : communications channel. + * Returns: 0 or a new association handle. + */ association *create_association(IOCHAN channel, COMSTACK link) { association *new; @@ -134,10 +153,6 @@ association *create_association(IOCHAN channel, COMSTACK link) } else new->print = 0; - if (!(new->encode_buffer = malloc(ENCODE_BUFFER_SIZE))) - return 0; - odr_setbuf(new->encode, new->encode_buffer, ENCODE_BUFFER_SIZE); - new->state = ASSOC_UNINIT; new->input_buffer = 0; new->input_buffer_len = 0; new->backend = 0; @@ -148,13 +163,15 @@ association *create_association(IOCHAN channel, COMSTACK link) return new; } +/* + * Free association and release resources. + */ void destroy_association(association *h) { odr_destroy(h->decode); odr_destroy(h->encode); if (h->print) odr_destroy(h->print); - free(h->encode_buffer); if (h->input_buffer) free(h->input_buffer); if (h->backend) @@ -162,6 +179,12 @@ void destroy_association(association *h) free(h); } +/* + * process events on the association. Called when the event loop detects an + * event. + * h : the I/O channel that has an outstanding event. + * event : the current outstanding event. + */ void ir_session(IOCHAN h, int event) { int res; @@ -219,6 +242,9 @@ void ir_session(IOCHAN h, int event) } } +/* + * Process the current outstanding APDU. + */ static int process_apdu(IOCHAN chan) { Z_APDU *apdu; @@ -252,7 +278,7 @@ static int process_apdu(IOCHAN chan) logf(LOG_WARN, "Bad APDU"); return -1; } - odr_reset(assoc->decode); /* release incopming APDU */ + odr_reset(assoc->decode); /* release incoming APDU */ odr_reset(assoc->encode); /* release stuff alloced before encoding */ return res; } @@ -278,7 +304,7 @@ static int process_initRequest(IOCHAN client, Z_InitRequest *req) binitreq.configname = "default-config"; if (!(binitres = bend_init(&binitreq)) || binitres->errcode) { - logf(LOG_WARN, "Bad response from backend"); + logf(LOG_WARN, "Negative response from backend"); return -1; } @@ -292,10 +318,14 @@ static int process_initRequest(IOCHAN client, Z_InitRequest *req) ODR_MASK_SET(&options, Z_Options_search); if (ODR_MASK_GET(req->options, Z_Options_present)) ODR_MASK_SET(&options, Z_Options_present); +#if 0 if (ODR_MASK_GET(req->options, Z_Options_delSet)) ODR_MASK_SET(&options, Z_Options_delSet); +#endif if (ODR_MASK_GET(req->options, Z_Options_namedResultSets)) ODR_MASK_SET(&options, Z_Options_namedResultSets); + if (ODR_MASK_GET(req->options, Z_Options_scan)) + ODR_MASK_SET(&options, Z_Options_scan); resp.options = &options; ODR_MASK_ZERO(&protocolVersion); if (ODR_MASK_GET(req->protocolVersion, Z_ProtocolVersion_1)) @@ -304,12 +334,8 @@ static int process_initRequest(IOCHAN client, Z_InitRequest *req) ODR_MASK_SET(&protocolVersion, Z_ProtocolVersion_2); resp.protocolVersion = &protocolVersion; assoc->maximumRecordSize = *req->maximumRecordSize; - /* - * This is not so hot. The big todo for ODR is dynamic memory allocation - * on encoding. - */ - if (assoc->maximumRecordSize > ENCODE_BUFFER_SIZE - 1000) - assoc->maximumRecordSize = ENCODE_BUFFER_SIZE - 1000; + if (assoc->maximumRecordSize > MAXRECORDSIZE) + assoc->maximumRecordSize = MAXRECORDSIZE; assoc->preferredMessageSize = *req->preferredMessageSize; if (assoc->preferredMessageSize > assoc->maximumRecordSize) assoc->preferredMessageSize = assoc->maximumRecordSize; @@ -317,8 +343,11 @@ static int process_initRequest(IOCHAN client, Z_InitRequest *req) resp.maximumRecordSize = &assoc->maximumRecordSize; resp.result = &result; resp.implementationId = "YAZ"; +#if 0 resp.implementationName = "Index Data/YAZ Generic Frontend Server"; - resp.implementationVersion = "$Revision: 1.17 $"; +#endif + resp.implementationName = "High Level API Server aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddduuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + resp.implementationVersion = "$Revision: 1.21 $"; resp.userInformationField = 0; if (!z_APDU(assoc->encode, &apdup, 0)) { @@ -326,7 +355,7 @@ static int process_initRequest(IOCHAN client, Z_InitRequest *req) odr_errlist[odr_geterror(assoc->encode)]); return -1; } - odr_getbuf(assoc->encode, &assoc->encoded_len); + assoc->encode_buffer = odr_getbuf(assoc->encode, &assoc->encoded_len); odr_reset(assoc->encode); iochan_setflags(client, EVENT_OUTPUT | EVENT_EXCEPT); return 0; @@ -635,7 +664,7 @@ static int process_searchRequest(IOCHAN client, Z_SearchRequest *req) odr_errlist[odr_geterror(assoc->encode)]); return -1; } - odr_getbuf(assoc->encode, &assoc->encoded_len); + assoc->encode_buffer = odr_getbuf(assoc->encode, &assoc->encoded_len); odr_reset(assoc->encode); iochan_setflags(client, EVENT_OUTPUT | EVENT_EXCEPT); return 0; @@ -669,7 +698,7 @@ static int process_presentRequest(IOCHAN client, Z_PresentRequest *req) odr_errlist[odr_geterror(assoc->encode)]); return -1; } - odr_getbuf(assoc->encode, &assoc->encoded_len); + assoc->encode_buffer = odr_getbuf(assoc->encode, &assoc->encoded_len); odr_reset(assoc->encode); iochan_setflags(client, EVENT_OUTPUT | EVENT_EXCEPT); return 0; @@ -727,7 +756,7 @@ static int process_scanRequest(IOCHAN client, Z_ScanRequest *req) if (srs->status == BEND_SCAN_PARTIAL) scanStatus = Z_Scan_partial_5; else - scanStatus = 1; /* Z_Scan_success; */ /* assumption for now */ + scanStatus = Z_Scan_success; ents.which = Z_ListEntries_entries; ents.u.entries = &list; list.entries = tab; @@ -764,11 +793,20 @@ static int process_scanRequest(IOCHAN client, Z_ScanRequest *req) } if (!z_APDU(assoc->encode, &apdup, 0)) { - logf(LOG_FATAL, "ODR error encoding initres: %s", + logf(LOG_FATAL, "ODR error encoding scanres: %s", + odr_errlist[odr_geterror(assoc->encode)]); + return -1; + } +#if 0 + odr_reset(assoc->print); + if (!z_APDU(assoc->print, &apdup, 0)) + { + logf(LOG_FATAL, "ODR error priniting scanres: %s", odr_errlist[odr_geterror(assoc->encode)]); return -1; } - odr_getbuf(assoc->encode, &assoc->encoded_len); +#endif + assoc->encode_buffer = odr_getbuf(assoc->encode, &assoc->encoded_len); odr_reset(assoc->encode); iochan_setflags(client, EVENT_OUTPUT | EVENT_EXCEPT); return 0;