1 /* This file is part of Pazpar2.
2 Copyright (C) 2006-2009 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
23 #include <yaz/comstack.h>
24 #include <yaz/pquery.h>
26 #include <yaz/yaz-ccl.h>
28 #include "termlists.h"
30 #include "pazpar2_config.h"
37 enum pazpar2_error_code {
41 PAZPAR2_MISSING_PARAMETER,
42 PAZPAR2_MALFORMED_PARAMETER_VALUE,
43 PAZPAR2_MALFORMED_PARAMETER_ENCODING,
44 PAZPAR2_MALFORMED_SETTING,
45 PAZPAR2_HITCOUNTS_FAILED,
46 PAZPAR2_RECORD_MISSING,
48 PAZPAR2_CONFIG_TARGET,
50 PAZPAR2_NOT_IMPLEMENTED,
55 enum pazpar2_database_criterion_type {
57 PAZPAR2_SUBSTRING_MATCH
60 // Represents a (virtual) database on a host
66 struct zr_explain *explain;
68 struct setting **settings;
69 struct database *next;
72 struct database_criterion_value {
74 struct database_criterion_value *next;
77 struct database_criterion {
79 enum pazpar2_database_criterion_type type;
80 struct database_criterion_value *values;
81 struct database_criterion *next;
84 // Represents a database as viewed from one session, possibly with settings overriden
86 struct session_database
88 struct database *database;
90 struct setting **settings;
91 normalize_record_t map;
92 struct session_database *next;
97 #define SESSION_WATCH_SHOW 0
98 #define SESSION_WATCH_RECORD 1
99 #define SESSION_WATCH_MAX 1
101 #define SESSION_MAX_TERMLISTS 10
103 typedef void (*session_watchfun)(void *data);
105 struct named_termlist
108 struct termlist *termlist;
111 struct session_watchentry {
113 http_channel_observer_t obs;
114 session_watchfun fun;
119 struct conf_service *service; /* service in use for this session */
120 struct session_database *databases; // All databases, settings overriden
121 struct client *clients; // Clients connected for current search
122 NMEM session_nmem; // Nmem for session-permanent storage
123 NMEM nmem; // Nmem for each operation (i.e. search, result set, etc)
124 WRBUF wrbuf; // Wrbuf for scratch(i.e. search)
126 struct named_termlist termlists[SESSION_MAX_TERMLISTS];
127 struct relevance *relevance;
128 struct reclist *reclist;
129 struct session_watchentry watchlist[SESSION_WATCH_MAX + 1];
133 int number_of_warnings_unknown_elements;
134 int number_of_warnings_unknown_metadata;
135 normalize_cache_t normalize_cache;
140 int num_no_connection;
150 struct hitsbytarget {
161 struct hitsbytarget *hitsbytarget(struct session *s, int *count, NMEM nmem);
162 int select_targets(struct session *se, struct database_criterion *crit);
163 struct session *new_session(NMEM nmem, struct conf_service *service);
164 void destroy_session(struct session *s);
165 void session_init_databases(struct session *s);
166 int load_targets(struct session *s, const char *fn);
167 void statistics(struct session *s, struct statistics *stat);
168 enum pazpar2_error_code search(struct session *s, const char *query,
169 const char *startrecs, const char *maxrecs,
170 const char *filter, const char **addinfo);
171 struct record_cluster **show(struct session *s, struct reclist_sortparms *sp, int start,
172 int *num, int *total, int *sumhits, NMEM nmem_show);
173 struct record_cluster *show_single(struct session *s, const char *id,
174 struct record_cluster **prev_r,
175 struct record_cluster **next_r);
176 struct termlist_score **termlist(struct session *s, const char *name, int *num);
177 int session_set_watch(struct session *s, int what, session_watchfun fun, void *data, struct http_channel *c);
178 int session_active_clients(struct session *s);
179 void session_apply_setting(struct session *se, char *dbname, char *setting, char *value);
180 const char *session_setting_oneval(struct session_database *db, int offset);
182 void pazpar2_add_channel(IOCHAN c);
183 void pazpar2_event_loop(void);
185 int host_getaddrinfo(struct host *host);
187 struct record *ingest_record(struct client *cl, const char *rec,
189 void session_alert_watch(struct session *s, int what);
190 void pull_terms(NMEM nmem, struct ccl_rpn_node *n, char **termlist, int *num);
197 * c-file-style: "Stroustrup"
198 * indent-tabs-mode: nil
200 * vim: shiftwidth=4 tabstop=8 expandtab