X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=server%2Fseshigh.c;h=9646fa72c278a4143c2de77eee2c648e66291a55;hb=61662168d4d4c1f7edb38cccac4b4a24dcecc58e;hp=d1d05b830f0f8d1f0ed969dc76f9640b5171cef3;hpb=102fffd24eb36b4b8322b3f139166ce5f5a4b7d4;p=yaz-moved-to-github.git diff --git a/server/seshigh.c b/server/seshigh.c index d1d05b8..9646fa7 100644 --- a/server/seshigh.c +++ b/server/seshigh.c @@ -4,7 +4,20 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: seshigh.c,v $ - * Revision 1.87 1999-03-31 11:18:25 adam + * 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. + * + * Revision 1.87 1999/03/31 11:18:25 adam * Implemented odr_strdup. Added Reference ID to backend server API. * * Revision 1.86 1999/02/02 13:57:38 adam @@ -536,7 +549,7 @@ void ir_session(IOCHAN h, int event) req = request_get(&assoc->incoming); /* get a new request structure */ odr_reset(assoc->decode); odr_setbuf(assoc->decode, assoc->input_buffer, res, 0); - if (!z_APDU(assoc->decode, &req->request, 0)) + if (!z_APDU(assoc->decode, &req->request, 0, 0)) { logf(LOG_LOG, "ODR error on incoming PDU: %s [near byte %d] ", odr_errmsg(odr_geterror(assoc->decode)), @@ -547,7 +560,7 @@ void ir_session(IOCHAN h, int event) return; } req->request_mem = odr_extract_mem(assoc->decode); - if (assoc->print && !z_APDU(assoc->print, &req->request, 0)) + if (assoc->print && !z_APDU(assoc->print, &req->request, 0, 0)) { logf(LOG_WARN, "ODR print error: %s", odr_errmsg(odr_geterror(assoc->print))); @@ -726,7 +739,7 @@ void backend_response(IOCHAN i, int event) static int process_response(association *assoc, request *req, Z_APDU *res) { odr_setbuf(assoc->encode, req->response, req->size_response, 1); - if (!z_APDU(assoc->encode, &res, 0)) + if (!z_APDU(assoc->encode, &res, 0, 0)) { logf(LOG_WARN, "ODR error when encoding response: %s", odr_errmsg(odr_geterror(assoc->decode))); @@ -736,7 +749,7 @@ static int process_response(association *assoc, request *req, Z_APDU *res) req->response = odr_getbuf(assoc->encode, &req->len_response, &req->size_response); odr_setbuf(assoc->encode, 0, 0, 0); /* don'txfree if we abort later */ - if (assoc->print && !z_APDU(assoc->print, &res, 0)) + if (assoc->print && !z_APDU(assoc->print, &res, 0, 0)) { logf(LOG_WARN, "ODR print error: %s", odr_errmsg(odr_geterror(assoc->print))); @@ -931,16 +944,12 @@ static Z_Records *diagrec(association *assoc, int error, char *addinfo) #if ASN_COMPILED rec->u.nonSurrogateDiagnostic = dr; #else -#ifdef Z_95 rec->u.nonSurrogateDiagnostic = drec; drec->which = Z_DiagRec_defaultFormat; drec->u.defaultFormat = dr; -#else - rec->u.nonSurrogateDiagnostic = dr; -#endif #endif - dr->diagnosticSetId = odr_oiddup (assoc->encode, - oid_ent_to_oid(&bib1, oid)); + dr->diagnosticSetId = + odr_oiddup (assoc->encode, oid_ent_to_oid(&bib1, oid)); dr->condition = err; set_addinfo (dr, addinfo); return rec; @@ -953,12 +962,14 @@ static Z_NamePlusRecord *surrogatediagrec(association *assoc, char *dbname, int error, char *addinfo) { int oid[OID_SIZE]; - Z_NamePlusRecord *rec = (Z_NamePlusRecord *)odr_malloc (assoc->encode, sizeof(*rec)); + Z_NamePlusRecord *rec = (Z_NamePlusRecord *) + odr_malloc (assoc->encode, sizeof(*rec)); int *err = (int *)odr_malloc (assoc->encode, sizeof(*err)); oident bib1; Z_DiagRec *drec = (Z_DiagRec *)odr_malloc (assoc->encode, sizeof(*drec)); - Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *)odr_malloc (assoc->encode, sizeof(*dr)); - + Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *) + odr_malloc (assoc->encode, sizeof(*dr)); + bib1.proto = assoc->proto; bib1.oclass = CLASS_DIAGSET; bib1.value = VAL_BIB1; @@ -1022,7 +1033,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)); @@ -1030,7 +1040,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; @@ -1048,9 +1057,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 @@ -1135,70 +1142,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; @@ -1817,21 +1764,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 will be processed...Good !"); + 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 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; }