-/* $Id: pazpar2.c,v 1.2 2006-12-20 22:19:35 adam Exp $ */;
+/* $Id: pazpar2.c,v 1.6 2006-12-27 21:11:10 quinn Exp $ */;
#include <stdlib.h>
#include <stdio.h>
#include <yaz/readconf.h>
#include <yaz/pquery.h>
#include <yaz/yaz-util.h>
+#include <yaz/nmem.h>
#include "pazpar2.h"
#include "eventl.h"
#include "termlists.h"
#include "reclists.h"
#include "relevance.h"
+#include "config.h"
#define PAZPAR2_VERSION "0.1"
#define MAX_CHUNK 15
0,
0,
0,
+ 0,
0
};
session_alert_watch(s, SESSION_WATCH_RECORDS);
}
+xsltStylesheetPtr load_stylesheet(const char *fname)
+{
+ xsltStylesheetPtr ret;
+ if (!(ret = xsltParseStylesheetFile((const xmlChar *) fname)))
+ {
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to load stylesheet %s", fname);
+ exit(1);
+ }
+ return ret;
+}
+
static void do_presentResponse(IOCHAN i, Z_APDU *a)
{
struct connection *co = iochan_getdata(i);
se = cl->session;
else
{
- yaz_log(YLOG_WARN, "Destroying orphan connection (fix me?)");
+ yaz_log(YLOG_WARN, "Destroying orphan connection");
connection_destroy(co);
return;
}
if ((res = getaddrinfo(url, port, &hints, &addrinfo)))
{
yaz_log(YLOG_WARN, "Failed to resolve %s: %s", url, gai_strerror(res));
+ xfree(host->hostport);
+ xfree(host);
continue;
}
assert(addrinfo->ai_family == PF_INET);
return termlist_highscore(s->termlist, num);
}
+#ifdef REPORT_NMEM
+// conditional compilation by SH: This lead to a warning with currently installed
+// YAZ header files on us1
void report_nmem_stats(void)
{
size_t in_use, is_free;
yaz_log(YLOG_LOG, "nmem stat: use=%ld free=%ld",
(long) in_use, (long) is_free);
}
+#endif
struct record **show(struct session *s, int start, int *num, int *total,
int *sumhits, NMEM nmem_show)
yaz_log_init(YLOG_DEFAULT_LEVEL, "pazpar2", 0);
- while ((ret = options("c:h:p:C:s:", argv, argc, &arg)) != -2)
+ while ((ret = options("f:x:c:h:p:C:s:", argv, argc, &arg)) != -2)
{
switch (ret) {
+ case 'f':
+ if (!read_config(arg))
+ exit(1);
+ break;
case 'c':
command_init(atoi(arg));
setport++;
case 's':
load_simpletargets(arg);
break;
+ case 'x':
+ global_parameters.xsl = load_stylesheet(arg);
+ break;
default:
fprintf(stderr, "Usage: pazpar2\n"
+ " -f configfile\n"
" -h [host:]port (REST protocol listener)\n"
" -c cmdport (telnet-style)\n"
" -C cclconfig\n"
exit(1);
}
- global_parameters.ccl_filter = load_cclfile("default.bib");
+ if (!global_parameters.xsl)
+ global_parameters.xsl = load_stylesheet("../etc/default.xsl");
+ global_parameters.ccl_filter = load_cclfile("../etc/default.bib");
global_parameters.yaz_marc = yaz_marc_create();
yaz_marc_subfield_str(global_parameters.yaz_marc, "\t");
global_parameters.odr_in = odr_createmem(ODR_DECODE);