1 /* $Id: pazpar2.h,v 1.44 2007-06-28 09:36:10 adam Exp $
2 Copyright (c) 2006-2007, Index Data.
4 This file is part of Pazpar2.
6 Pazpar2 is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with Pazpar2; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
28 #include <libxslt/xsltutils.h>
29 #include <libxslt/transform.h>
31 #include <yaz/comstack.h>
32 #include <yaz/pquery.h>
34 #include <yaz/yaz-ccl.h>
36 #include "termlists.h"
37 #include "relevance.h"
41 #include "parameters.h"
48 enum pazpar2_error_code {
52 PAZPAR2_MISSING_PARAMETER,
53 PAZPAR2_MALFORMED_PARAMETER_VALUE,
54 PAZPAR2_MALFORMED_PARAMETER_ENCODING,
55 PAZPAR2_MALFORMED_SETTING,
56 PAZPAR2_HITCOUNTS_FAILED,
57 PAZPAR2_RECORD_MISSING,
59 PAZPAR2_CONFIG_TARGET,
61 PAZPAR2_NOT_IMPLEMENTED,
66 // Represents a (virtual) database on a host
72 struct zr_explain *explain;
73 struct setting **settings;
74 struct database *next;
77 struct database_criterion_value {
79 struct database_criterion_value *next;
82 struct database_criterion {
84 struct database_criterion_value *values;
85 struct database_criterion *next;
88 // Normalization filter. Turns incoming record into internal representation
89 // Simple sequence of stylesheets run in series.
90 struct database_retrievalmap {
91 xsltStylesheet *stylesheet;
92 struct database_retrievalmap *next;
95 // Represents a database as viewed from one session, possibly with settings overriden
97 struct session_database
100 struct database *database;
101 struct setting **settings;
103 struct database_retrievalmap *map;
104 struct session_database *next;
107 #define SESSION_WATCH_RECORDS 0
108 #define SESSION_WATCH_MAX 0
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);
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, int 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 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, Z_External *rec);
196 xmlDoc *record_to_xml(struct session_database *sdb, Z_External *rec);
198 struct record *ingest_record(struct client *cl, Z_External *rec,
200 void session_alert_watch(struct session *s, int what);
201 void pull_terms(NMEM nmem, struct ccl_rpn_node *n, char **termlist, int *num);
203 int pazpar2_process(int debug, int daemon,
204 void (*work)(void *data), void *data,
205 const char *pidfile, const char *uid);
213 * indent-tabs-mode: nil
215 * vim: shiftwidth=4 tabstop=8 expandtab