Added setting to specify pqf prefix, to support database subset selection, etc.
[pazpar2-moved-to-github.git] / src / client.c
index ad9d237..6473597 100644 (file)
@@ -21,13 +21,25 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     \brief Z39.50 client 
 */
 
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#if HAVE_SYS_TIME_H
 #include <sys/time.h>
+#endif
+#if HAVE_UNISTD_H
 #include <unistd.h>
+#endif
+#if HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
+#endif
+#if HAVE_NETDB_H
 #include <netdb.h>
+#endif
 #include <signal.h>
 #include <ctype.h>
 #include <assert.h>
@@ -46,16 +58,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <yaz/oid_db.h>
 #include <yaz/diagbib1.h>
 
-#if HAVE_CONFIG_H
-#include "cconfig.h"
-#endif
-
 #define USE_TIMING 0
 #if USE_TIMING
 #include <yaz/timing.h>
 #endif
 
+#if HAVE_NETINET_IN_H
 #include <netinet/in.h>
+#endif
 
 #include "pazpar2.h"
 
@@ -980,6 +990,8 @@ int client_parse_query(struct client *cl, const char *query)
     struct ccl_rpn_node *cn;
     int cerror, cpos;
     CCL_bibset ccl_map = prepare_cclmap(cl);
+    struct session_database *sdb = client_get_database(cl);
+    const char *pqf_prefix = session_setting_oneval(sdb, PZ_PQF_PREFIX);
 
     if (!ccl_map)
         return -1;
@@ -994,6 +1006,11 @@ int client_parse_query(struct client *cl, const char *query)
         return -1;
     }
     wrbuf_rewind(se->wrbuf);
+    if (*pqf_prefix)
+    {
+        wrbuf_puts(se->wrbuf, pqf_prefix);
+        wrbuf_puts(se->wrbuf, " ");
+    }
     ccl_pquery(se->wrbuf, cn);
     xfree(cl->pquery);
     cl->pquery = xstrdup(wrbuf_cstr(se->wrbuf));