permanent data.
/*
- * $Id: http_command.c,v 1.30 2007-04-08 23:04:20 adam Exp $
+ * $Id: http_command.c,v 1.31 2007-04-10 00:53:24 quinn Exp $
*/
#include <stdio.h>
struct session *psession;
unsigned int session_id;
int timestamp;
+ NMEM nmem;
struct http_session *next;
};
struct http_session *http_session_create()
{
- struct http_session *r = xmalloc(sizeof(*r));
- r->psession = new_session();
+ NMEM nmem = nmem_create();
+ struct http_session *r = nmem_malloc(nmem, sizeof(*r));
+
+ r->psession = new_session(nmem);
r->session_id = 0;
r->timestamp = 0;
+ r->nmem = nmem;
r->next = session_list;
session_list = r;
r->timeout_iochan = iochan_create(-1, session_timeout, 0);
}
iochan_destroy(s->timeout_iochan);
destroy_session(s->psession);
- xfree(s);
+ nmem_destroy(s->nmem);
}
static void error(struct http_response *rs, char *code, char *msg, char *txt)
-/* $Id: pazpar2.c,v 1.67 2007-04-08 23:04:20 adam Exp $ */
+/* $Id: pazpar2.c,v 1.68 2007-04-10 00:53:24 quinn Exp $ */
#include <stdlib.h>
#include <stdio.h>
se->clients = cl;
}
-// This should be extended with parameters to control selection criteria
// Associates a set of clients with a session;
int select_targets(struct session *se, struct database_criterion *crit)
{
criteria = parse_filter(se->nmem, filter);
strcpy(se->query, query);
se->requestid++;
- // Release any existing clients
select_targets(se, criteria);
for (cl = se->clients; cl; cl = cl->next)
{
wrbuf_destroy(s->wrbuf);
}
-struct session *new_session()
+struct session *new_session(NMEM nmem)
{
int i;
- struct session *session = xmalloc(sizeof(*session));
+ struct session *session = nmem_malloc(nmem, sizeof(*session));
yaz_log(YLOG_DEBUG, "New pazpar2 session");
session->clients = 0;
session->expected_maxrecs = 0;
session->query[0] = '\0';
+ session->session_nmem = nmem;
session->nmem = nmem_create();
session->wrbuf = wrbuf_alloc();
for (i = 0; i <= SESSION_WATCH_MAX; i++)
struct termlist *termlist;
};
+// Represents a database as viewed from one session, possibly with settings overriden
+// for that session (to support authorization/authentication)
+struct session_database
+{
+ struct database *database;
+ struct setting *settings;
+ struct session_database *next;
+};
+
// End-user session
struct session {
struct client *clients;
int requestid;
char query[1024];
- NMEM nmem; // Nmem for each operation (i.e. search)
+ NMEM session_nmem; // Nmem for session-permanent storage
+ NMEM nmem; // Nmem for each operation (i.e. search, result set, etc)
WRBUF wrbuf; // Wrbuf for scratch(i.e. search)
int num_termlists;
struct named_termlist termlists[SESSION_MAX_TERMLISTS];
struct hitsbytarget *hitsbytarget(struct session *s, int *count);
int select_targets(struct session *se, struct database_criterion *crit);
-struct session *new_session();
+struct session *new_session(NMEM nmem);
void destroy_session(struct session *s);
int load_targets(struct session *s, const char *fn);
void statistics(struct session *s, struct statistics *stat);
-// $Id: settings.c,v 1.8 2007-04-08 21:51:58 quinn Exp $
+// $Id: settings.c,v 1.9 2007-04-10 00:53:24 quinn Exp $
// This module implements a generic system of settings (attribute-value) that can
// be associated with search targets. The system supports both default values,
// per-target overrides, and per-user settings.
"pz:xslt",
"pz:nativesyntax",
"pz:authentication",
+ "pz:allow",
+ "pz:maxrecs",
0
};
#define PZ_XSLT 5
#define PZ_NATIVESYNTAX 6
#define PZ_AUTHENTICATION 7
+#define PZ_ALLOW 8
+#define PZ_MAXRECS 9
struct setting
{