-/* $Id: pazpar2.c,v 1.9 2006-12-04 02:27:02 quinn Exp $ */;
+/* $Id: pazpar2.c,v 1.12 2006-12-12 02:36:24 quinn Exp $ */;
#include <stdlib.h>
#include <stdio.h>
#include <yaz/readconf.h>
#include <yaz/pquery.h>
#include <yaz/yaz-util.h>
-#include <yaz/ccl.h>
-#include <yaz/yaz-ccl.h>
#include "pazpar2.h"
#include "eventl.h"
"Client_Stopped"
};
-static struct parameters {
- int timeout; /* operations timeout, in seconds */
- char implementationId[128];
- char implementationName[128];
- char implementationVersion[128];
- int target_timeout; // seconds
- int toget;
- int chunk;
- CCL_bibset ccl_filter;
- yaz_marc_t yaz_marc;
- ODR odr_out;
- ODR odr_in;
-} global_parameters =
+struct parameters global_parameters =
{
30,
"81",
"Index Data PazPar2 (MasterKey)",
PAZPAR2_VERSION,
600, // 10 minutes
+ 60,
100,
MAX_CHUNK,
0,
}
}
wrbuf_putc(s->wrbuf, '\0');
- obuf = nmem_strdup(s->nmem, wrbuf_buf(s->wrbuf));
+ obuf = (unsigned char*) nmem_strdup(s->nmem, wrbuf_buf(s->wrbuf));
for (p = obuf; *p; p++)
if (*p == '&' || *p == '<' || *p > 122 || *p < ' ')
*p = ' ';
- return obuf;
+ return (char*) obuf;
}
// Extract 245 $a $b 100 $a
cc->next = c->next;
}
if (c->connection)
- connection_destroy(c->connection);
+ connection_release(c->connection);
c->next = client_freelist;
client_freelist = c;
}
return 0;
}
+void destroy_session(struct session *s)
+{
+ yaz_log(YLOG_LOG, "Destroying session");
+ while (s->clients)
+ client_destroy(s->clients);
+ nmem_destroy(s->nmem);
+ wrbuf_free(s->wrbuf, 1);
+}
+
struct session *new_session()
{
struct session *session = xmalloc(sizeof(*session));
return session;
}
-void session_destroy(struct session *s)
-{
- // FIXME do some shit here!!!!
-}
-
struct hitsbytarget *hitsbytarget(struct session *se, int *count)
{
static struct hitsbytarget res[1000]; // FIXME MM
{
int ret;
char *arg;
+ int setport = 0;
if (signal(SIGPIPE, SIG_IGN) < 0)
yaz_log(YLOG_WARN|YLOG_ERRNO, "signal");
while ((ret = options("c:h:p:C:s:", argv, argc, &arg)) != -2)
{
switch (ret) {
- case 0:
- break;
case 'c':
command_init(atoi(arg));
+ setport++;
break;
- case 'C':
- global_parameters.ccl_filter = load_cclfile(arg);
- break;
case 'h':
http_init(atoi(arg));
+ setport++;
+ break;
+ case 'C':
+ global_parameters.ccl_filter = load_cclfile(arg);
break;
case 'p':
http_set_proxyaddr(arg);
load_simpletargets(arg);
break;
default:
- fprintf(stderr, "Usage: pazpar2 -d comport");
+ fprintf(stderr, "Usage: pazpar2\n"
+ " -h httpport (REST)\n"
+ " -c cmdport (telnet-style)\n"
+ " -C cclconfig\n"
+ " -s simpletargetfile\n"
+ " -p hostname[:portno] (HTTP proxy)\n");
exit(1);
}
}
+ if (!setport)
+ {
+ fprintf(stderr, "Set command port with -h or -c\n");
+ exit(1);
+ }
+
global_parameters.ccl_filter = load_cclfile("default.bib");
global_parameters.yaz_marc = yaz_marc_create();
yaz_marc_subfield_str(global_parameters.yaz_marc, "\t");