-/* $Id: logic.c,v 1.42 2007-06-13 13:04:34 adam Exp $
+/* $Id: logic.c,v 1.45 2007-06-15 19:35:17 adam Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
#include <yaz/nmem.h>
#include <yaz/query-charset.h>
#include <yaz/querytowrbuf.h>
-#if YAZ_VERSIONL >= 0x020163
#include <yaz/oid_db.h>
-#endif
#if HAVE_CONFIG_H
#include "cconfig.h"
termlist_insert(s->termlists[i].termlist, value);
}
-xmlDoc *normalize_record(struct session_database *sdb, Z_External *rec)
+xmlDoc *record_to_xml(struct session_database *sdb, Z_External *rec)
{
- struct database_retrievalmap *m;
struct database *db = sdb->database;
xmlDoc *rdoc = 0;
const Odr_oid *oid = rec->direct_reference;
xmlDocDump(stderr, rdoc);
#endif
}
+ return rdoc;
+}
- for (m = sdb->map; m; m = m->next){
- xmlDoc *new = 0;
-
- {
- xmlNodePtr root = 0;
- new = xsltApplyStylesheet(m->stylesheet, rdoc, 0);
- root= xmlDocGetRootElement(new);
- if (!new || !root || !(root->children))
- {
- yaz_log(YLOG_WARN, "XSLT transformation failed from %s",
- sdb->database->url);
- xmlFreeDoc(new);
+xmlDoc *normalize_record(struct session_database *sdb, Z_External *rec)
+{
+ struct database_retrievalmap *m;
+ xmlDoc *rdoc = record_to_xml(sdb, rec);
+ if (rdoc)
+ {
+ for (m = sdb->map; m; m = m->next){
+ xmlDoc *new = 0;
+
+ {
+ xmlNodePtr root = 0;
+ new = xsltApplyStylesheet(m->stylesheet, rdoc, 0);
+ root= xmlDocGetRootElement(new);
+ if (!new || !root || !(root->children))
+ {
+ yaz_log(YLOG_WARN, "XSLT transformation failed from %s",
+ sdb->database->url);
+ xmlFreeDoc(new);
+ xmlFreeDoc(rdoc);
+ return 0;
+ }
+ }
+
xmlFreeDoc(rdoc);
- return 0;
- }
+ rdoc = new;
}
-
- xmlFreeDoc(rdoc);
- rdoc = new;
- }
- if (global_parameters.dump_records)
- {
- fprintf(stderr, "Record from %s\n----------------\n",
- sdb->database->url);
+ if (global_parameters.dump_records)
+ {
+ fprintf(stderr, "Record from %s\n----------------\n",
+ sdb->database->url);
#if LIBXML_VERSION >= 20600
- xmlDocFormatDump(stderr, rdoc, 1);
+ xmlDocFormatDump(stderr, rdoc, 1);
#else
- xmlDocDump(stderr, rdoc);
+ xmlDocDump(stderr, rdoc);
#endif
+ }
}
return rdoc;
}
return 0;
}
+// called if watch should be removed because http_channel is to be destroyed
+static void session_watch_cancel(void *data, struct http_channel *c)
+{
+ struct session_watchentry *ent = data;
+
+ ent->fun = 0;
+ ent->data = 0;
+ ent->obs = 0;
+}
-void session_set_watch(struct session *s, int what,
- session_watchfun fun, void *data)
+// set watch. Returns 0=OK, -1 if watch is already set
+int session_set_watch(struct session *s, int what,
+ session_watchfun fun, void *data,
+ struct http_channel *chan)
{
+ if (s->watchlist[what].fun)
+ return -1;
s->watchlist[what].fun = fun;
s->watchlist[what].data = data;
+ s->watchlist[what].obs = http_add_observer(chan, &s->watchlist[what],
+ session_watch_cancel);
+ return 0;
}
void session_alert_watch(struct session *s, int what)
{
if (!s->watchlist[what].fun)
return;
+ http_remove_observer(s->watchlist[what].obs);
(*s->watchlist[what].fun)(s->watchlist[what].data);
s->watchlist[what].fun = 0;
s->watchlist[what].data = 0;
+ s->watchlist[what].obs = 0;
}
//callback for grep_databases
}
record = record_create(se->nmem,
- service->num_metadata, service->num_sortkeys, cl);
+ service->num_metadata, service->num_sortkeys, cl,
+ record_no);
mergekey_norm = (xmlChar *) nmem_strdup(se->nmem, (char*) mergekey);
xmlFree(mergekey);