Added --with-yc option to configure. For the data1_node in data1.h:
[yaz-moved-to-github.git] / server / seshigh.c
index 3233f05..44d69f7 100644 (file)
@@ -4,7 +4,19 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: seshigh.c,v $
- * Revision 1.78  1998-08-03 10:23:55  adam
+ * Revision 1.82  1998-10-20 14:00:30  quinn
+ * Fixed Scan
+ *
+ * Revision 1.81  1998/10/13 16:12:24  adam
+ * Added support for Surrogate Diagnostics for Scan Term entries.
+ *
+ * Revision 1.80  1998/09/02 12:41:53  adam
+ * Added decode stream in bend search structures.
+ *
+ * Revision 1.79  1998/08/19 16:10:08  adam
+ * Changed som member names of DeleteResultSetRequest/Response.
+ *
+ * Revision 1.78  1998/08/03 10:23:55  adam
  * Fixed bug regarding Options for Sort.
  *
  * Revision 1.77  1998/07/20 12:38:42  adam
@@ -879,11 +891,15 @@ static void set_addinfo (Z_DefaultDiagFormat *dr, char *addinfo)
 static Z_Records *diagrec(association *assoc, int error, char *addinfo)
 {
     int oid[OID_SIZE];
-    Z_Records *rec = (Z_Records *)odr_malloc (assoc->encode, sizeof(*rec));
+    Z_Records *rec = (Z_Records *)
+       odr_malloc (assoc->encode, sizeof(*rec));
     oident bib1;
-    int *err = (int *)odr_malloc (assoc->encode, sizeof(*err));
-    Z_DiagRec *drec = (Z_DiagRec *)odr_malloc (assoc->encode, sizeof(*drec));
-    Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *)odr_malloc (assoc->encode, sizeof(*dr));
+    int *err = (int *)
+       odr_malloc (assoc->encode, sizeof(*err));
+    Z_DiagRec *drec = (Z_DiagRec *)
+       odr_malloc (assoc->encode, sizeof(*drec));
+    Z_DefaultDiagFormat *dr = (Z_DefaultDiagFormat *)
+       odr_malloc (assoc->encode, sizeof(*dr));
 
     bib1.proto = assoc->proto;
     bib1.oclass = CLASS_DIAGSET;
@@ -1186,6 +1202,7 @@ static Z_APDU *process_searchRequest(association *assoc, request *reqb,
        bsrr->basenames = req->databaseNames;
        bsrr->query = req->query;
        bsrr->stream = assoc->encode;
+       bsrr->decode = assoc->decode;
        bsrr->errcode = 0;
        bsrr->hits = 0;
        bsrr->errstring = NULL;
@@ -1204,6 +1221,7 @@ static Z_APDU *process_searchRequest(association *assoc, request *reqb,
        bsrq.basenames = req->databaseNames;
        bsrq.query = req->query;
        bsrq.stream = assoc->encode;
+       bsrq.decode = assoc->decode;
        if (!(bsrt = bend_search(assoc->backend, &bsrq, fd)))
            return 0;
        bsrr->hits = bsrt->hits;
@@ -1432,14 +1450,10 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd)
     res->numberOfEntriesReturned = numberOfEntriesReturned;
     res->positionOfTerm = 0;
     res->entries = ents;
-#if ASN_COMPILED
     ents->num_entries = 0;
     ents->entries = NULL;
     ents->num_nonsurrogateDiagnostics = 0;
     ents->nonsurrogateDiagnostics = NULL;
-#else
-    ents->which = Z_ListEntries_entries;
-#endif
     res->attributeSet = 0;
     res->otherInfo = 0;
 
@@ -1474,11 +1488,6 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd)
        else
        {
            int i;
-#ifdef ASN_COMPILED
-#else
-           Z_Entries *list = (Z_Entries *)
-               odr_malloc (assoc->encode, sizeof(*list));
-#endif
             Z_Entry **tab = (Z_Entry **)
                odr_malloc (assoc->encode, sizeof(*tab) * srs->num_entries);
            
@@ -1486,16 +1495,9 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd)
                *scanStatus = Z_Scan_partial_5;
            else
                *scanStatus = Z_Scan_success;
-#ifdef ASN_COMPILED
            ents->entries = tab;
            ents->num_entries = srs->num_entries;
            res->numberOfEntriesReturned = &ents->num_entries;      
-#else
-           ents->u.entries = list;
-           list->entries = tab;
-           list->num_entries = srs->num_entries;
-           res->numberOfEntriesReturned = &list->num_entries;
-#endif
            res->positionOfTerm = &srs->term_position;
            for (i = 0; i < srs->num_entries; i++)
            {
@@ -1504,35 +1506,50 @@ static Z_APDU *process_scanRequest(association *assoc, request *reqb, int *fd)
                Odr_oct *o;
                
                tab[i] = e = (Z_Entry *)odr_malloc(assoc->encode, sizeof(*e));
-               e->which = Z_Entry_termInfo;
-               e->u.termInfo = t = (Z_TermInfo *)odr_malloc(assoc->encode, sizeof(*t));
-               t->suggestedAttributes = 0;
-               t->displayTerm = 0;
-               t->alternativeTerm = 0;
-               t->byAttributes = 0;
-               t->otherTermInfo = 0;
-               t->globalOccurrences = &srs->entries[i].occurrences;
-               t->term = (Z_Term *)odr_malloc(assoc->encode, sizeof(*t->term));
-               t->term->which = Z_Term_general;
-               t->term->u.general = o = (Odr_oct *)odr_malloc(assoc->encode,
-                   sizeof(Odr_oct));
-               o->buf = (unsigned char *)odr_malloc(assoc->encode, o->len = o->size =
-                   strlen(srs->entries[i].term));
-               memcpy(o->buf, srs->entries[i].term, o->len);
-               logf(LOG_DEBUG, "  term #%d: '%s' (%d)", i,
-                   srs->entries[i].term, srs->entries[i].occurrences);
+               if (srs->entries[i].occurrences >= 0)
+               {
+                   e->which = Z_Entry_termInfo;
+                   e->u.termInfo = t = (Z_TermInfo *)
+                       odr_malloc(assoc->encode, sizeof(*t));
+                   t->suggestedAttributes = 0;
+                   t->displayTerm = 0;
+                   t->alternativeTerm = 0;
+                   t->byAttributes = 0;
+                   t->otherTermInfo = 0;
+                   t->globalOccurrences = &srs->entries[i].occurrences;
+                   t->term = (Z_Term *)
+                       odr_malloc(assoc->encode, sizeof(*t->term));
+                   t->term->which = Z_Term_general;
+                   t->term->u.general = o =
+                       (Odr_oct *)odr_malloc(assoc->encode, sizeof(Odr_oct));
+                   o->buf = (unsigned char *)
+                       odr_malloc(assoc->encode, o->len = o->size =
+                                  strlen(srs->entries[i].term));
+                   memcpy(o->buf, srs->entries[i].term, o->len);
+                   logf(LOG_DEBUG, "  term #%d: '%s' (%d)", i,
+                        srs->entries[i].term, srs->entries[i].occurrences);
+               }
+               else
+               {
+                   Z_Records *zrecords = diagrec (assoc,
+                                                  srs->entries[i].errcode,
+                                                  srs->entries[i].errstring);
+                   logf(LOG_DEBUG, "  term sd code=%d addinfo=%s",
+                        srs->entries[i].errcode,
+                        (srs->entries[i].errstring?srs->entries[i].errstring :
+                         "<null>"));
+                   assert (zrecords->which == Z_Records_NSD);
+                   e->which = Z_Entry_surrogateDiagnostic;
+                   e->u.surrogateDiagnostic =
+                       zrecords->u.nonSurrogateDiagnostic;
+               }
            }
        }
     }
     if (diagrecs_p)
     {
-#ifdef ASN_COMPILED
        ents->num_nonsurrogateDiagnostics = diagrecs_p->num_diagRecs;
        ents->nonsurrogateDiagnostics = diagrecs_p->diagRecs;
-#else
-       ents->u.nonSurrogateDiagnostics = diagrecs_p;
-       ents->which = Z_ListEntries_nonSurrogateDiagnostics;
-#endif
     }
     return apdu;
 }
@@ -1605,7 +1622,7 @@ static Z_APDU *process_deleteRequest(association *assoc, request *reqb,
 
     logf(LOG_LOG, "Got DeleteRequest.");
 
-    bdrr->num_setnames = req->num_ids;
+    bdrr->num_setnames = req->num_resultSetList;
     bdrr->setnames = req->resultSetList;
     bdrr->stream = assoc->encode;
     bdrr->function = *req->deleteFunction;
@@ -1619,10 +1636,8 @@ static Z_APDU *process_deleteRequest(association *assoc, request *reqb,
        odr_malloc (assoc->encode, sizeof(*res->deleteOperationStatus));
     *res->deleteOperationStatus = bdrr->delete_status;
 
-    res->num_statuses = 0;
     res->deleteListStatuses = 0;
     res->numberNotDeleted = 0;
-    res->num_bulkStatuses = 0;
     res->bulkStatuses = 0;
     res->deleteMessage = 0;
     res->otherInfo = 0;