X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=server%2Fseshigh.c;h=e89e830050c058b0d169132e6ed29ea5e2afd690;hb=a0bdc8bbd4d346939e7c24fd7e07b6d361d78643;hp=121f212de99a601ede7b850a56f8d10d716c420c;hpb=e147ddf129696b470aed3cfcdb405af84ee56ef6;p=yaz-moved-to-github.git diff --git a/server/seshigh.c b/server/seshigh.c index 121f212..e89e830 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -4,7 +4,23 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: seshigh.c,v $ - * Revision 1.88 1999-04-20 09:56:48 adam + * Revision 1.93 1999-07-06 12:17:15 adam + * Added option -1 that runs server once (for profiling purposes). + * + * Revision 1.92 1999/06/17 10:54:45 adam + * Added facility to specify implementation version - and name + * for server. + * + * Revision 1.91 1999/06/01 14:29:12 adam + * Work on Extended Services. + * + * Revision 1.90 1999/05/27 13:02:20 adam + * Assigned OID for old DB Update (VAL_DBUPDATE0). + * + * Revision 1.89 1999/05/26 15:24:26 adam + * Fixed minor bugs regarding DB Update (introduced by previous commit). + * + * Revision 1.88 1999/04/20 09:56:48 adam * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun). * Modified all encoders/decoders to reflect this change. * @@ -438,6 +454,8 @@ void destroy_association(association *h) request_delq(&h->incoming); request_delq(&h->outgoing); xfree(h); + if (control_block && control_block->one_shot) + exit (0); } static void do_close_req(association *a, int reason, char *message, @@ -790,6 +808,8 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb) binitreq.configname = "default-config"; binitreq.auth = req->idAuthentication; binitreq.referenceId = req->referenceId; + binitreq.implementation_version = 0; + binitreq.implementation_name = 0; binitreq.bend_sort = NULL; binitreq.bend_search = NULL; binitreq.bend_present = NULL; @@ -881,7 +901,30 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb) assoc->preferredMessageSize = assoc->maximumRecordSize; resp->preferredMessageSize = &assoc->preferredMessageSize; resp->maximumRecordSize = &assoc->maximumRecordSize; + resp->implementationName = "Index Data/YAZ Generic Frontend Server"; + + if (binitreq.implementation_name) + { + char *nv = (char *) + odr_malloc (assoc->encode, + strlen(binitreq.implementation_name) + 3 + + strlen(resp->implementationName)); + sprintf (nv, "%s %s", + resp->implementationName, binitreq.implementation_name); + resp->implementationName = nv; + } + if (binitreq.implementation_version) + { + char *nv = (char *) + odr_malloc (assoc->encode, + strlen(binitreq.implementation_version) + 3 + + strlen(resp->implementationVersion)); + sprintf (nv, "%s %s", + resp->implementationVersion, binitreq.implementation_version); + resp->implementationVersion = nv; + } + if (binitres->errcode) { logf(LOG_LOG, "Connection rejected by backend."); @@ -1024,7 +1067,6 @@ static Z_Records *pack_records(association *a, char *setname, int start, int *next, int *pres, oid_value format, Z_ReferenceId *referenceId) { - int oid[OID_SIZE]; int recno, total_length = 0, toget = *num, dumped_records = 0; Z_Records *records = (Z_Records *) odr_malloc (a->encode, sizeof(*records)); @@ -1032,7 +1074,6 @@ static Z_Records *pack_records(association *a, char *setname, int start, (Z_NamePlusRecordList *) odr_malloc (a->encode, sizeof(*reclist)); Z_NamePlusRecord **list = (Z_NamePlusRecord **) odr_malloc (a->encode, sizeof(*list) * toget); - oident recform; records->which = Z_Records_DBOSD; records->u.databaseOrSurDiagnostics = reclist; @@ -1050,9 +1091,7 @@ static Z_Records *pack_records(association *a, char *setname, int start, bend_fetchrequest freq; bend_fetchresult *fres; Z_NamePlusRecord *thisrec; - Z_DatabaseRecord *thisext; int this_length = 0; - /* * we get the number of bytes allocated on the stream before any * allocation done by the backend - this should give us a reasonable @@ -1137,70 +1176,10 @@ static Z_Records *pack_records(association *a, char *setname, int start, return 0; strcpy(thisrec->databaseName, fres->basename); thisrec->which = Z_NamePlusRecord_databaseRecord; - if (!(thisrec->u.databaseRecord = thisext = (Z_External *) - odr_malloc(a->encode, sizeof(Z_DatabaseRecord)))) + thisrec->u.databaseRecord = z_ext_record(a->encode, fres->format, + fres->record, fres->len); + if (!thisrec->u.databaseRecord) return 0; - recform.proto = a->proto; - recform.oclass = CLASS_RECSYN; - recform.value = fres->format; - thisext->direct_reference = - odr_oiddup(a->encode, oid_ent_to_oid(&recform, oid)); - thisext->indirect_reference = 0; - thisext->descriptor = 0; - if (fres->len < 0) /* Structured data */ - { - switch (fres->format) - { - case VAL_SUTRS: thisext->which = Z_External_sutrs; break; - case VAL_GRS1: thisext->which = Z_External_grs1; break; - case VAL_EXPLAIN: thisext->which = Z_External_explainRecord; - break; - case VAL_SUMMARY: thisext->which = Z_External_summary; break; - case VAL_OPAC: thisext->which = Z_External_OPAC; break; - - default: - logf(LOG_FATAL, "Unknown structured format from backend."); - return 0; - } - - /* - * We cheat on the pointers here. Obviously, the record field - * of the backend-fetch structure should have been a union for - * correctness, but we're stuck with this for backwards - * compatibility. - */ - thisext->u.grs1 = (Z_GenericRecord*) fres->record; - } - else if (fres->format == VAL_SUTRS) /* SUTRS is a single-ASN.1-type */ - { -#if 0 - Z_SUTRS *sutrs = (Z_SUTRS *)odr_malloc(a->encode, 1+fres->len); - - memcpy(sutrs, fres->record, fres->len); - sutrs[fres->len] = '\0'; -#else - Odr_oct *sutrs = (Odr_oct *)odr_malloc(a->encode, sizeof(*sutrs)); - - thisext->which = Z_External_sutrs; - thisext->u.sutrs = sutrs; - sutrs->buf = (unsigned char *)odr_malloc(a->encode, fres->len); - sutrs->len = sutrs->size = fres->len; - memcpy(sutrs->buf, fres->record, fres->len); -#endif - } - else /* octet-aligned record. */ - { - thisext->which = Z_External_octet; - if (!(thisext->u.octet_aligned = (Odr_oct *)odr_malloc(a->encode, - sizeof(Odr_oct)))) - return 0; - if (!(thisext->u.octet_aligned->buf = (unsigned char *) - odr_malloc(a->encode, fres->len))) - return 0; - memcpy(thisext->u.octet_aligned->buf, fres->record, fres->len); - thisext->u.octet_aligned->len = thisext->u.octet_aligned->size = - fres->len; - } reclist->records[reclist->num_records] = thisrec; reclist->num_records++; *next = fres->last_in_set ? 0 : recno + 1; @@ -1819,21 +1798,31 @@ static Z_APDU *process_ESRequest(association *assoc, request *reqb, int *fd) resp->referenceId = req->referenceId; - if ( esrequest.errcode == 0 ) + if (esrequest.errcode == -1) + { + /* Backend service indicates request will be processed */ + logf(LOG_DEBUG,"Request could be processed...Accepted !"); + *resp->operationStatus = Z_ExtendedServicesResponse_accepted; + } + else if (esrequest.errcode == 0) { /* Backend service indicates request will be processed */ - logf(LOG_DEBUG,"Request will be processed...Good !"); + logf(LOG_DEBUG,"Request could be processed...Done !"); *resp->operationStatus = Z_ExtendedServicesResponse_done; } else { + Z_DiagRecs *diagRecs = diagrecs (assoc, esrequest.errcode, + esrequest.errstring); + /* Backend indicates error, request will not be processed */ - logf(LOG_DEBUG,"Request will not be processed...BAD !"); + logf(LOG_DEBUG,"Request could not be processed...failure !"); *resp->operationStatus = Z_ExtendedServicesResponse_failure; + resp->num_diagnostics = diagRecs->num_diagRecs; + resp->diagnostics = diagRecs->diagRecs; } /* Do something with the members of bend_extendedservice */ logf(LOG_DEBUG,"Send the result apdu"); - return apdu; }