1 /* This file is part of Pazpar2.
2 Copyright (C) 2006-2011 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
20 #ifndef PAZPAR2_SESSION_H
21 #define PAZPAR2_SESSION_H
23 #include <yaz/comstack.h>
24 #include <yaz/pquery.h>
26 #include <yaz/yaz-ccl.h>
28 #include "termlists.h"
36 enum pazpar2_error_code {
40 PAZPAR2_MISSING_PARAMETER,
41 PAZPAR2_MALFORMED_PARAMETER_VALUE,
42 PAZPAR2_MALFORMED_PARAMETER_ENCODING,
43 PAZPAR2_MALFORMED_SETTING,
44 PAZPAR2_HITCOUNTS_FAILED,
45 PAZPAR2_RECORD_MISSING,
47 PAZPAR2_CONFIG_TARGET,
49 PAZPAR2_NOT_IMPLEMENTED,
55 // Represents a database
59 struct setting **settings;
60 struct database *next;
64 // Represents a database as viewed from one session, possibly with settings overriden
66 struct session_database
68 struct database *database;
70 struct setting **settings;
71 normalize_record_t map;
72 struct session_database *next;
75 #define SESSION_WATCH_SHOW 0
76 #define SESSION_WATCH_RECORD 1
77 #define SESSION_WATCH_SHOW_PREF 2
78 #define SESSION_WATCH_MAX 2
80 #define SESSION_MAX_TERMLISTS 10
82 typedef void (*session_watchfun)(void *data);
87 struct termlist *termlist;
90 struct session_watchentry {
92 http_channel_observer_t obs;
100 struct conf_service *service; /* service in use for this session */
101 struct session_database *databases; // All databases, settings overriden
102 struct client_list *clients; // Clients connected for current search
103 struct client_list *clients_cached; // Clients in cache
104 NMEM session_nmem; // Nmem for session-permanent storage
105 NMEM nmem; // Nmem for each operation (i.e. search, result set, etc)
107 struct named_termlist termlists[SESSION_MAX_TERMLISTS];
108 struct relevance *relevance;
109 struct reclist *reclist;
110 struct session_watchentry watchlist[SESSION_WATCH_MAX + 1];
113 int number_of_warnings_unknown_elements;
114 int number_of_warnings_unknown_metadata;
115 normalize_cache_t normalize_cache;
116 YAZ_MUTEX session_mutex;
118 int settings_modified;
119 struct session_sorted_results *sorted_results;
124 int num_no_connection;
134 struct hitsbytarget {
143 char *suggestions_xml;
146 struct hitsbytarget *get_hitsbytarget(struct session *s, int *count, NMEM nmem);
147 struct session *new_session(NMEM nmem, struct conf_service *service,
148 unsigned session_id);
149 void destroy_session(struct session *s);
150 void session_init_databases(struct session *s);
151 void statistics(struct session *s, struct statistics *stat);
153 void session_sort(struct session *se, const char *field, int increasing);
155 enum pazpar2_error_code session_search(struct session *s, const char *query,
156 const char *startrecs,
158 const char *filter, const char *limit,
159 const char **addinfo,
160 const char *sort_field, int increasing);
161 struct record_cluster **show_range_start(struct session *s,
162 struct reclist_sortparms *sp,
164 int *num, int *total, Odr_int *sumhits);
165 void show_range_stop(struct session *s, struct record_cluster **recs);
167 struct record_cluster *show_single_start(struct session *s, const char *id,
168 struct record_cluster **prev_r,
169 struct record_cluster **next_r);
170 void show_single_stop(struct session *s, struct record_cluster *rec);
171 struct termlist_score **get_termlist_score(struct session *s,
172 const char *name, int *num);
173 int session_set_watch(struct session *s, int what, session_watchfun fun, void *data, struct http_channel *c);
174 int session_active_clients(struct session *s);
175 int session_is_preferred_clients_ready(struct session *s);
176 void session_apply_setting(struct session *se, char *dbname, char *setting, char *value);
177 const char *session_setting_oneval(struct session_database *db, int offset);
179 int ingest_record(struct client *cl, const char *rec, int record_no, NMEM nmem);
180 void session_alert_watch(struct session *s, int what);
181 void add_facet(struct session *s, const char *type, const char *value, int count);
183 void perform_termlist(struct http_channel *c, struct session *se,
184 const char *name, int num);
185 void session_log(struct session *s, int level, const char *fmt, ...)
187 __attribute__ ((format (printf, 3, 4)))
195 * c-file-style: "Stroustrup"
196 * indent-tabs-mode: nil
198 * vim: shiftwidth=4 tabstop=8 expandtab