Work on Extended Services.
[yaz-moved-to-github.git] / server / seshigh.c
index faa1f63..9646fa7 100644 (file)
@@ -4,7 +4,13 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: seshigh.c,v $
- * Revision 1.89  1999-05-26 15:24:26  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
@@ -1027,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));
@@ -1035,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;
@@ -1053,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
@@ -1762,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;
 }