1 /* $Id: pazpar2.h,v 1.51 2008-02-18 19:33:32 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
99 struct database *database;
100 struct setting **settings;
102 struct database_retrievalmap *map;
103 struct session_database *next;
108 #define SESSION_WATCH_SHOW 0
109 #define SESSION_WATCH_RECORD 1
110 #define SESSION_WATCH_MAX 1
112 #define SESSION_MAX_TERMLISTS 10
114 typedef void (*session_watchfun)(void *data);
116 struct named_termlist
119 struct termlist *termlist;
122 struct session_watchentry {
124 http_channel_observer_t obs;
125 session_watchfun fun;
130 struct session_database *databases; // All databases, settings overriden
131 struct client *clients; // Clients connected for current search
133 NMEM session_nmem; // Nmem for session-permanent storage
134 NMEM nmem; // Nmem for each operation (i.e. search, result set, etc)
135 WRBUF wrbuf; // Wrbuf for scratch(i.e. search)
137 struct named_termlist termlists[SESSION_MAX_TERMLISTS];
138 struct relevance *relevance;
139 struct reclist *reclist;
140 struct session_watchentry watchlist[SESSION_WATCH_MAX + 1];
141 int expected_maxrecs;
149 int num_no_connection;
151 int num_initializing;
161 struct hitsbytarget {
171 struct hitsbytarget *hitsbytarget(struct session *s, int *count, NMEM nmem);
172 int select_targets(struct session *se, struct database_criterion *crit);
173 struct session *new_session(NMEM nmem);
174 void destroy_session(struct session *s);
175 void session_init_databases(struct session *s);
176 int load_targets(struct session *s, const char *fn);
177 void statistics(struct session *s, struct statistics *stat);
178 enum pazpar2_error_code search(struct session *s, char *query,
179 char *filter, const char **addinfo);
180 struct record_cluster **show(struct session *s, struct reclist_sortparms *sp, int start,
181 int *num, int *total, int *sumhits, NMEM nmem_show);
182 struct record_cluster *show_single(struct session *s, const char *id);
183 struct termlist_score **termlist(struct session *s, const char *name, int *num);
184 int session_set_watch(struct session *s, int what, session_watchfun fun, void *data, struct http_channel *c);
185 int session_active_clients(struct session *s);
186 void session_apply_setting(struct session *se, char *dbname, char *setting, char *value);
187 const char *session_setting_oneval(struct session_database *db, int offset);
189 void start_http_listener(void);
190 void start_proxy(void);
192 void pazpar2_add_channel(IOCHAN c);
193 void pazpar2_event_loop(void);
195 int host_getaddrinfo(struct host *host);
197 xmlDoc *normalize_record(struct session_database *sdb, struct session *se,
199 xmlDoc *record_to_xml(struct session_database *sdb, Z_External *rec);
201 struct record *ingest_record(struct client *cl, Z_External *rec,
203 void session_alert_watch(struct session *s, int what);
204 void pull_terms(NMEM nmem, struct ccl_rpn_node *n, char **termlist, int *num);
211 * indent-tabs-mode: nil
213 * vim: shiftwidth=4 tabstop=8 expandtab