Also added a test for command=bytarget.
-/* $Id: http_command.c,v 1.58 2007-08-17 12:39:11 adam Exp $
+/* $Id: http_command.c,v 1.59 2007-09-05 07:24:04 adam Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
- * $Id: http_command.c,v 1.58 2007-08-17 12:39:11 adam Exp $
+ * $Id: http_command.c,v 1.59 2007-09-05 07:24:04 adam Exp $
}
// This implements functionality somewhat similar to 'bytarget', but in a termlist form
}
// This implements functionality somewhat similar to 'bytarget', but in a termlist form
-static void targets_termlist(WRBUF wrbuf, struct session *se, int num)
+static void targets_termlist(WRBUF wrbuf, struct session *se, int num,
+ NMEM nmem)
{
struct hitsbytarget *ht;
int count, i;
{
struct hitsbytarget *ht;
int count, i;
- if (!(ht = hitsbytarget(se, &count)))
- return;
+ ht = hitsbytarget(se, &count, nmem);
qsort(ht, count, sizeof(struct hitsbytarget), cmp_ht);
for (i = 0; i < count && i < num && ht[i].hits > 0; i++)
{
qsort(ht, count, sizeof(struct hitsbytarget), cmp_ht);
for (i = 0; i < count && i < num && ht[i].hits > 0; i++)
{
wrbuf_xmlputs(c->wrbuf, tname);
wrbuf_puts(c->wrbuf, "\">\n");
if (!strcmp(tname, "xtargets"))
wrbuf_xmlputs(c->wrbuf, tname);
wrbuf_puts(c->wrbuf, "\">\n");
if (!strcmp(tname, "xtargets"))
- targets_termlist(c->wrbuf, s->psession, num);
+ targets_termlist(c->wrbuf, s->psession, num, c->nmem);
else
{
p = termlist(s->psession, tname, &len);
else
{
p = termlist(s->psession, tname, &len);
- if (!(ht = hitsbytarget(s->psession, &count)))
- {
- error(rs, PAZPAR2_HITCOUNTS_FAILED, 0);
- return;
- }
+ ht = hitsbytarget(s->psession, &count, c->nmem);
wrbuf_rewind(c->wrbuf);
wrbuf_puts(c->wrbuf, "<bytarget><status>OK</status>");
wrbuf_rewind(c->wrbuf);
wrbuf_puts(c->wrbuf, "<bytarget><status>OK</status>");
-/* $Id: logic.c,v 1.62 2007-08-17 12:39:11 adam Exp $
+/* $Id: logic.c,v 1.63 2007-09-05 07:24:04 adam Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
-struct hitsbytarget *hitsbytarget(struct session *se, int *count)
+struct hitsbytarget *hitsbytarget(struct session *se, int *count, NMEM nmem)
- static struct hitsbytarget res[1000]; // FIXME MM
+ struct hitsbytarget *res = 0;
+ for (cl = se->clients; cl; cl = client_next_in_session(cl))
+ sz++;
+
+ res = nmem_malloc(nmem, sizeof(*res) * sz);
*count = 0;
for (cl = se->clients; cl; cl = client_next_in_session(cl))
{
*count = 0;
for (cl = se->clients; cl; cl = client_next_in_session(cl))
{
res[*count].connected = client_get_connection(cl) ? 1 : 0;
(*count)++;
}
res[*count].connected = client_get_connection(cl) ? 1 : 0;
(*count)++;
}
-/* $Id: pazpar2.h,v 1.47 2007-08-17 12:39:11 adam Exp $
+/* $Id: pazpar2.h,v 1.48 2007-09-05 07:24:04 adam Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
-struct hitsbytarget *hitsbytarget(struct session *s, int *count);
+struct hitsbytarget *hitsbytarget(struct session *s, int *count, NMEM nmem);
int select_targets(struct session *se, struct database_criterion *crit);
struct session *new_session(NMEM nmem);
void destroy_session(struct session *s);
int select_targets(struct session *se, struct database_criterion *crit);
struct session *new_session(NMEM nmem);
void destroy_session(struct session *s);
--- /dev/null
+<bytarget><status>OK</status>
+<target><id>z3950.indexdata.com/gils</id>
+<hits>0</hits>
+<diagnostic>0</diagnostic>
+<records>0</records>
+<state>Client_Idle</state>
+</target></bytarget>
\ No newline at end of file
http://localhost:9763/search.pz2?session=2&command=show&start=0&number=1&block=1
http://localhost:9763/search.pz2?session=2&command=search&query=kubiak%20stanis%C5%82aw
http://localhost:9763/search.pz2?session=2&command=search&query=kubiak%20sts%C5%82aw
http://localhost:9763/search.pz2?session=2&command=show&start=0&number=1&block=1
http://localhost:9763/search.pz2?session=2&command=search&query=kubiak%20stanis%C5%82aw
http://localhost:9763/search.pz2?session=2&command=search&query=kubiak%20sts%C5%82aw
+http://localhost:9763/search.pz2?session=2&command=bytarget