Added typecast and removed bad assignment
[yaz-moved-to-github.git] / src / seshigh.c
index 1bdede6..8e7a00f 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2004, Index Data
  * See the file LICENSE for details.
  *
- * $Id: seshigh.c,v 1.23 2004-03-29 15:09:14 adam Exp $
+ * $Id: seshigh.c,v 1.29 2004-09-30 11:15:52 adam Exp $
  */
 
 /*
@@ -510,9 +510,22 @@ static int srw_bend_fetch(association *assoc, int pos,
 
     rr.comp->u.complex->generic = (Z_Specification *) 
            odr_malloc(assoc->decode, sizeof(Z_Specification));
+
+    /* schema uri = recordSchema (or NULL if recordSchema is not given) */
     rr.comp->u.complex->generic->which = Z_Schema_uri;
     rr.comp->u.complex->generic->schema.uri = srw_req->recordSchema;
+
+    /* ESN = recordSchema if recordSchema is present */
     rr.comp->u.complex->generic->elementSpec = 0;
+    if (srw_req->recordSchema)
+    {
+       rr.comp->u.complex->generic->elementSpec = 
+           (Z_ElementSpec *) odr_malloc(assoc->encode, sizeof(Z_ElementSpec));
+       rr.comp->u.complex->generic->elementSpec->which = 
+           Z_ElementSpec_elementSetName;
+       rr.comp->u.complex->generic->elementSpec->u.elementSetName =
+           srw_req->recordSchema;
+    }
     
     rr.stream = assoc->encode;
     rr.print = assoc->print;
@@ -606,7 +619,8 @@ static void srw_bend_search(association *assoc, request *req,
             const char *pqf_msg;
             size_t off;
             int code = yaz_pqf_error (pqf_parser, &pqf_msg, &off);
-            yaz_log(LOG_LOG, "%*s^\n", off+4, "");
+           if (off < 200)
+               yaz_log(LOG_LOG, "%*s^\n", (int)off+4, "");
             yaz_log(LOG_LOG, "Bad PQF: %s (code %d)\n", pqf_msg, code);
             
             srw_error = 10;
@@ -649,7 +663,6 @@ static void srw_bend_search(association *assoc, request *req,
     rr.search_info = 0;
     yaz_log_zquery(rr.query);
     (assoc->init->bend_search)(assoc->backend, &rr);
-    srw_res->numberOfRecords = odr_intdup(assoc->encode, rr.hits);
     if (rr.errcode)
     {
         yaz_log(LOG_DEBUG, "bend_search returned Bib-1 code %d", rr.errcode);
@@ -1033,6 +1046,8 @@ static int process_z_request(association *assoc, request *req, char **msg)
            return -1;
        }
        break;
+    case Z_APDU_triggerResourceControlRequest:
+       return 0;
     default:
        *msg = "Bad APDU received";
        return -1;
@@ -1285,6 +1300,8 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
        ODR_MASK_SET(resp->options, Z_Options_negotiationModel);
        strcat(options, " negotiation");
     }
+       
+    ODR_MASK_SET(resp->options, Z_Options_triggerResourceCtrl);
 
     if (ODR_MASK_GET(req->protocolVersion, Z_ProtocolVersion_1))
     {
@@ -1321,7 +1338,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
                assoc->init->implementation_name,
                odr_prepend(assoc->encode, "GFS", resp->implementationName));
 
-    version = odr_strdup(assoc->encode, "$Revision: 1.23 $");
+    version = odr_strdup(assoc->encode, "$Revision: 1.29 $");
     if (strlen(version) > 10)  /* check for unexpanded CVS strings */
        version[strlen(version)-2] = '\0';
     resp->implementationVersion = odr_prepend(assoc->encode,
@@ -1499,7 +1516,7 @@ static Z_Records *pack_records(association *a, char *setname, int start,
     records->u.databaseOrSurDiagnostics = reclist;
     reclist->num_records = 0;
     reclist->records = list;
-    *pres = Z_PRES_SUCCESS;
+    *pres = Z_PresentStatus_success;
     *num = 0;
     *next = 0;
 
@@ -1543,7 +1560,7 @@ static Z_Records *pack_records(association *a, char *setname, int start,
            if (!freq.surrogate_flag)
            {
                char s[20];
-               *pres = Z_PRES_FAILURE;
+               *pres = Z_PresentStatus_failure;
                /* for 'present request out of range',
                    set addinfo to record position if not set */
                if (freq.errcode == 13 && freq.errstring == 0)
@@ -1573,7 +1590,7 @@ static Z_Records *pack_records(association *a, char *setname, int start,
            if (this_length <= a->preferredMessageSize && recno > start)
            {
                yaz_log(LOG_DEBUG, "  Dropped last normal-sized record");
-               *pres = Z_PRES_PARTIAL_2;
+               *pres = Z_PresentStatus_partial_2;
                break;
            }
            /* record can only be fetched by itself */
@@ -1693,7 +1710,7 @@ static Z_APDU *response_searchRequest(association *assoc, request *reqb,
     int *nulint = odr_intdup (assoc->encode, 0);
     bool_t *sr = odr_intdup(assoc->encode, 1);
     int *next = odr_intdup(assoc->encode, 0);
-    int *none = odr_intdup(assoc->encode, Z_RES_NONE);
+    int *none = odr_intdup(assoc->encode, Z_SearchResponse_none);
 
     apdu->which = Z_APDU_searchResponse;
     apdu->u.searchResponse = resp;
@@ -1839,7 +1856,7 @@ static Z_APDU *process_presentRequest(association *assoc, request *reqb,
        if (bprr->errcode)
        {
            resp->records = diagrec(assoc, bprr->errcode, bprr->errstring);
-           *resp->presentStatus = Z_PRES_FAILURE;
+           *resp->presentStatus = Z_PresentStatus_failure;
        }
     }
     apdu = (Z_APDU *)odr_malloc (assoc->encode, sizeof(*apdu));
@@ -2053,7 +2070,7 @@ static Z_APDU *process_sortRequest(association *assoc, request *reqb,
     bsrr->stream = assoc->encode;
     bsrr->print = assoc->print;
 
-    bsrr->sort_status = Z_SortStatus_failure;
+    bsrr->sort_status = Z_SortResponse_failure;
     bsrr->errcode = 0;
     bsrr->errstring = 0;