A chapter about the yaz-client was added to the documentation.
[yaz-moved-to-github.git] / server / seshigh.c
index 1beb970..0bd8ba5 100644 (file)
@@ -3,7 +3,16 @@
  * See the file LICENSE for details.
  *
  * $Log: seshigh.c,v $
- * Revision 1.104  2000-04-05 07:39:55  adam
+ * Revision 1.107  2000-08-31 10:20:12  adam
+ * Added member request_format and output_format for backend fetch method.
+ *
+ * Revision 1.106  2000/08/31 09:51:25  adam
+ * Added record_syntax member for fetch method (raw OID).
+ *
+ * Revision 1.105  2000/07/06 10:38:47  adam
+ * Enhanced option --enable-tcpd.
+ *
+ * Revision 1.104  2000/04/05 07:39:55  adam
  * Added shared library support (libtool).
  *
  * Revision 1.103  2000/03/20 19:06:25  adam
@@ -668,6 +677,11 @@ static int process_request(association *assoc, request *req, char **msg)
     
     *msg = "Unknown Error";
     assert(req && req->state == REQUEST_IDLE);
+    if (req->request->which != Z_APDU_initRequest && !assoc->init)
+    {
+       *msg = "Missing InitRequest";
+       return -1;
+    }
     switch (req->request->which)
     {
     case Z_APDU_initRequest:
@@ -1130,9 +1144,10 @@ static Z_DiagRecs *diagrecs(association *assoc, int error, char *addinfo)
 }
 
 static Z_Records *pack_records(association *a, char *setname, int start,
-                               int *num, Z_RecordComposition *comp,
-                               int *next, int *pres, oid_value format,
-                               Z_ReferenceId *referenceId)
+                              int *num, Z_RecordComposition *comp,
+                              int *next, int *pres, oid_value format,
+                              Z_ReferenceId *referenceId,
+                              int *oid)
 {
     int recno, total_length = 0, toget = *num, dumped_records = 0;
     Z_Records *records =
@@ -1175,7 +1190,9 @@ static Z_Records *pack_records(association *a, char *setname, int start,
        freq.number = recno;
        freq.comp = comp;
        freq.request_format = format;
-       freq.output_format = 0;
+       freq.request_format_raw = oid;
+       freq.output_format = format;
+       freq.output_format_raw = 0;
        freq.stream = a->encode;
        freq.print = a->print;
        freq.surrogate_flag = 0;
@@ -1247,6 +1264,12 @@ static Z_Records *pack_records(association *a, char *setname, int start,
            return 0;
        strcpy(thisrec->databaseName, freq.basename);
        thisrec->which = Z_NamePlusRecord_databaseRecord;
+
+       if (freq.output_format_raw)
+       {
+           struct oident *ident = oid_getentbyoid(freq.output_format_raw);
+           freq.output_format = ident->value;
+       }
        thisrec->u.databaseRecord = z_ext_record(a->encode, freq.output_format,
                                                 freq.record, freq.len);
        if (!thisrec->u.databaseRecord)
@@ -1415,7 +1438,8 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
            else
                form = prefformat->value;
            resp->records = pack_records(assoc, req->resultSetName, 1,
-               toget, compp, next, presst, form, req->referenceId);
+               toget, compp, next, presst, form, req->referenceId,
+                                        req->preferredRecordSyntax);
            if (!resp->records)
                return 0;
            resp->numberOfRecordsReturned = toget;
@@ -1454,7 +1478,7 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
  * speed - which is normally more true for search than for present.
  */
 static Z_APDU *process_presentRequest(association *assoc, request *reqb,
-    int *fd)
+                                     int *fd)
 {
     Z_PresentRequest *req = reqb->request->u.presentRequest;
     oident *prefformat;
@@ -1510,7 +1534,7 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb,
     resp->records =
        pack_records(assoc, req->resultSetId, *req->resultSetStartPoint,
                     num, req->recordComposition, next, presst, form,
-                     req->referenceId);
+                     req->referenceId, req->preferredRecordSyntax);
     if (!resp->records)
        return 0;
     resp->numberOfRecordsReturned = num;