Empty backendelementset results in no elementset
[yazproxy-moved-to-github.git] / src / yaz-proxy.cpp
index c80c99a..6865413 100644 (file)
@@ -293,6 +293,7 @@ Yaz_Proxy::Yaz_Proxy(IPDU_Observable *the_PDU_Observable,
     m_usemarcon = new Yaz_usemarcon();
     if (!m_parent)
         low_socket_open();
+    m_backend_elementset = 0;
     m_my_thread = 0;
     m_ref_count = 1;
     m_main_ptr_dec = false;
@@ -333,11 +334,14 @@ Yaz_Proxy::~Yaz_Proxy()
     xfree(m_backend_charset);
     xfree(m_usemarcon_ini_stage1);
     xfree(m_usemarcon_ini_stage2);
+    xfree(m_backend_elementset);
     delete m_usemarcon;
     if (m_s2z_odr_init)
         odr_destroy(m_s2z_odr_init);
     if (m_s2z_odr_search)
         odr_destroy(m_s2z_odr_search);
+    if (m_s2z_odr_scan)
+        odr_destroy(m_s2z_odr_scan);
     if (!m_parent)
         low_socket_close();
     if (!m_parent)
@@ -2723,7 +2727,8 @@ Z_APDU *Yaz_Proxy::handle_syntax_validation(Z_APDU *apdu)
                                     &addinfo, &stylesheet_name, &m_schema,
                                     &m_backend_type, &m_backend_charset,
                                     &m_usemarcon_ini_stage1,
-                                    &m_usemarcon_ini_stage2);
+                                    &m_usemarcon_ini_stage2,
+                                    &m_backend_elementset);
         if (stylesheet_name)
         {
             m_parent->low_socket_close();
@@ -2769,6 +2774,15 @@ Z_APDU *Yaz_Proxy::handle_syntax_validation(Z_APDU *apdu)
                 yaz_string_to_oid_odr(yaz_oid_std(), CLASS_RECSYN,
                                       m_backend_type, odr_encode());
         }
+        if (m_backend_elementset)
+        {
+            Z_ElementSetNames *esn =
+                mk_esn_from_schema(
+                    odr_encode(),
+                    *m_backend_elementset ? m_backend_elementset : 0);
+            sr->smallSetElementSetNames = esn;
+            sr->mediumSetElementSetNames = esn;
+        }
     }
     else if (apdu->which == Z_APDU_presentRequest)
     {
@@ -2790,8 +2804,8 @@ Z_APDU *Yaz_Proxy::handle_syntax_validation(Z_APDU *apdu)
                                     &addinfo, &stylesheet_name, &m_schema,
                                     &m_backend_type, &m_backend_charset,
                                     &m_usemarcon_ini_stage1,
-                                    &m_usemarcon_ini_stage2
-                                    );
+                                    &m_usemarcon_ini_stage2,
+                                    &m_backend_elementset);
         if (stylesheet_name)
         {
             m_parent->low_socket_close();
@@ -2839,6 +2853,18 @@ Z_APDU *Yaz_Proxy::handle_syntax_validation(Z_APDU *apdu)
                                       CLASS_RECSYN, m_backend_type,
                                       odr_encode());
         }
+        if (m_backend_elementset)
+        {
+            Z_ElementSetNames *esn =
+                mk_esn_from_schema(
+                    odr_encode(),
+                    *m_backend_elementset ? m_backend_elementset : 0);
+            Z_RecordComposition *comp = (Z_RecordComposition *)
+                odr_malloc(odr_encode(), sizeof(Z_RecordComposition));
+            comp->which = Z_RecordComp_simple;
+            comp->u.simple = esn;
+            pr->recordComposition = comp;
+        }
     }
     return apdu;
 }