Fix formatting inconsistency.
[yaz-moved-to-github.git] / src / seshigh.c
index e28b63a..343eea2 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: seshigh.c,v 1.58 2005-06-25 15:46:05 adam Exp $
+ * $Id: seshigh.c,v 1.63 2005-09-16 09:16:40 adam Exp $
  */
 /**
  * \file seshigh.c
@@ -243,6 +243,7 @@ static void do_close_req(association *a, int reason, char *message,
         request_release(req);
         yaz_log(log_requestdetail, "v2 client. No Close PDU");
         iochan_setevent(a->client_chan, EVENT_TIMEOUT); /* force imm close */
+        a->cs_put_mask = 0;
     }
     a->state = ASSOC_DEAD;
 }
@@ -722,7 +723,8 @@ static void srw_bend_search(association *assoc, request *req,
         rr.basenames = &srw_req->database;
         rr.referenceId = 0;
         rr.srw_sortKeys = 0;
-        
+        rr.srw_setname = 0;
+        rr.srw_setnameIdleTime = 0;
         rr.query = (Z_Query *) odr_malloc (assoc->decode, sizeof(*rr.query));
         rr.query->u.type_1 = 0;
         
@@ -827,6 +829,13 @@ static void srw_bend_search(association *assoc, request *req,
                         start, number, rr.hits);
                 
                 srw_res->numberOfRecords = odr_intdup(assoc->encode, rr.hits);
+               if (rr.srw_setname)
+                {
+                    srw_res->resultSetId =
+                        odr_strdup(assoc->encode, rr.srw_setname );
+                    srw_res->resultSetIdleTime =
+                        odr_intdup(assoc->encode, *rr.srw_setnameIdleTime );
+               }
                 if (number > 0)
                 {
                     int i;
@@ -930,7 +939,7 @@ static char *srw_bend_explain_default(void *handle, bend_explain_rr *rr)
         if (!strcmp((const char *) ptr->name, "explain"))
         {
             int len;
-            xmlDocPtr doc = xmlNewDoc("1.0");
+            xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
             xmlChar *buf_out;
             char *content;
 
@@ -1595,7 +1604,10 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
 
     if (control_association(assoc, get_vhost(req->otherInfo), 1))
         cb = statserv_getcontrol();  /* got control block for backend */
-    
+
+    if (cb && assoc->backend)
+        (*cb->bend_close)(assoc->backend);
+
     yaz_log(log_requestdetail, "Got initRequest");
     if (req->implementationId)
         yaz_log(log_requestdetail, "Id:        %s",
@@ -1620,7 +1632,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
             negotiation->which == Z_CharSetandLanguageNegotiation_proposal)
             assoc->init->charneg_request = negotiation;
     }
-    
+
     assoc->backend = 0;
     if (cb)
     {
@@ -1764,7 +1776,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.58 $");
+    version = odr_strdup(assoc->encode, "$Revision: 1.63 $");
     if (strlen(version) > 10)   /* check for unexpanded CVS strings */
         version[strlen(version)-2] = '\0';
     resp->implementationVersion = odr_prepend(assoc->encode,
@@ -1782,6 +1794,38 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
     }
     if (log_request)
     {
+        if (!req->idAuthentication)
+            yaz_log(log_request, "Auth none");
+        else if (req->idAuthentication->which == Z_IdAuthentication_open)
+        {
+            const char *open = req->idAuthentication->u.open;
+            const char *slash = strchr(open, '/');
+            int len;
+            if (slash)
+                len = slash - open;
+            else
+                len = strlen(open);
+                yaz_log(log_request, "Auth open %.*s", len, open);
+        }
+        else if (req->idAuthentication->which == Z_IdAuthentication_idPass)
+        {
+            const char *user = req->idAuthentication->u.idPass->userId;
+            const char *group = req->idAuthentication->u.idPass->groupId;
+            yaz_log(log_request, "Auth idPass %s %s",
+                    user ? user : "-", group ? group : "-");
+        }
+        else if (req->idAuthentication->which 
+                 == Z_IdAuthentication_anonymous)
+        {
+            yaz_log(log_request, "Auth anonymous");
+        }
+        else
+        {
+            yaz_log(log_request, "Auth other");
+        }
+    }
+    if (log_request)
+    {
         WRBUF wr = wrbuf_alloc();
         wrbuf_printf(wr, "Init ");
         if (binitres->errcode)
@@ -2012,6 +2056,8 @@ static Z_APDU *process_searchRequest(association *assoc, request *reqb,
     bsrr->referenceId = req->referenceId;
     save_referenceId (reqb, bsrr->referenceId);
     bsrr->srw_sortKeys = 0;
+    bsrr->srw_setname = 0;
+    bsrr->srw_setnameIdleTime = 0;
 
     yaz_log (log_requestdetail, "ResultSet '%s'", req->resultSetName);
     if (req->databaseNames)