1 /* This file is part of Pazpar2.
2 Copyright (C) 2006-2008 Index Data
4 Pazpar2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <libxslt/xsltutils.h>
27 #include <libxslt/transform.h>
29 #include <yaz/comstack.h>
30 #include <yaz/pquery.h>
32 #include <yaz/yaz-ccl.h>
34 #include "termlists.h"
35 #include "relevance.h"
38 #include "pazpar2_config.h"
39 #include "parameters.h"
46 enum pazpar2_error_code {
50 PAZPAR2_MISSING_PARAMETER,
51 PAZPAR2_MALFORMED_PARAMETER_VALUE,
52 PAZPAR2_MALFORMED_PARAMETER_ENCODING,
53 PAZPAR2_MALFORMED_SETTING,
54 PAZPAR2_HITCOUNTS_FAILED,
55 PAZPAR2_RECORD_MISSING,
57 PAZPAR2_CONFIG_TARGET,
59 PAZPAR2_NOT_IMPLEMENTED,
64 // Represents a (virtual) database on a host
70 struct zr_explain *explain;
71 struct setting **settings;
72 struct database *next;
75 struct database_criterion_value {
77 struct database_criterion_value *next;
80 struct database_criterion {
82 struct database_criterion_value *values;
83 struct database_criterion *next;
86 // Normalization filter. Turns incoming record into internal representation
87 // Simple sequence of stylesheets run in series.
88 struct database_retrievalmap {
89 xsltStylesheet *stylesheet;
90 struct database_retrievalmap *next;
93 // Represents a database as viewed from one session, possibly with settings overriden
95 struct session_database
97 struct database *database;
98 struct setting **settings;
100 struct database_retrievalmap *map;
101 struct session_database *next;
106 #define SESSION_WATCH_SHOW 0
107 #define SESSION_WATCH_RECORD 1
108 #define SESSION_WATCH_MAX 1
110 #define SESSION_MAX_TERMLISTS 10
112 typedef void (*session_watchfun)(void *data);
114 struct named_termlist
117 struct termlist *termlist;
120 struct session_watchentry {
122 http_channel_observer_t obs;
123 session_watchfun fun;
128 struct session_database *databases; // All databases, settings overriden
129 struct client *clients; // Clients connected for current search
131 NMEM session_nmem; // Nmem for session-permanent storage
132 NMEM nmem; // Nmem for each operation (i.e. search, result set, etc)
133 WRBUF wrbuf; // Wrbuf for scratch(i.e. search)
135 struct named_termlist termlists[SESSION_MAX_TERMLISTS];
136 struct relevance *relevance;
137 struct reclist *reclist;
138 struct session_watchentry watchlist[SESSION_WATCH_MAX + 1];
139 int expected_maxrecs;
147 int num_no_connection;
149 int num_initializing;
159 struct hitsbytarget {
169 struct hitsbytarget *hitsbytarget(struct session *s, int *count, NMEM nmem);
170 int select_targets(struct session *se, struct database_criterion *crit);
171 struct session *new_session(NMEM nmem);
172 void destroy_session(struct session *s);
173 void session_init_databases(struct session *s);
174 int load_targets(struct session *s, const char *fn);
175 void statistics(struct session *s, struct statistics *stat);
176 enum pazpar2_error_code search(struct session *s, char *query,
177 char *filter, const char **addinfo);
178 struct record_cluster **show(struct session *s, struct reclist_sortparms *sp, int start,
179 int *num, int *total, int *sumhits, NMEM nmem_show);
180 struct record_cluster *show_single(struct session *s, const char *id);
181 struct termlist_score **termlist(struct session *s, const char *name, int *num);
182 int session_set_watch(struct session *s, int what, session_watchfun fun, void *data, struct http_channel *c);
183 int session_active_clients(struct session *s);
184 void session_apply_setting(struct session *se, char *dbname, char *setting, char *value);
185 const char *session_setting_oneval(struct session_database *db, int offset);
187 void start_http_listener(void);
188 void start_proxy(void);
190 void pazpar2_add_channel(IOCHAN c);
191 void pazpar2_event_loop(void);
193 int host_getaddrinfo(struct host *host);
195 xmlDoc *normalize_record(struct session_database *sdb, struct session *se,
197 xmlDoc *record_to_xml(struct session_database *sdb, Z_External *rec);
199 struct record *ingest_record(struct client *cl, Z_External *rec,
201 void session_alert_watch(struct session *s, int what);
202 void pull_terms(NMEM nmem, struct ccl_rpn_node *n, char **termlist, int *num);
209 * indent-tabs-mode: nil
211 * vim: shiftwidth=4 tabstop=8 expandtab