- return "NOTARGETS";
-
- 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()
-{
- int i;
- struct session *session = xmalloc(sizeof(*session));
-
- yaz_log(YLOG_DEBUG, "New pazpar2 session");
-
- session->total_hits = 0;
- session->total_records = 0;
- session->num_termlists = 0;
- session->reclist = 0;
- session->requestid = -1;
- session->clients = 0;
- session->expected_maxrecs = 0;
- session->query[0] = '\0';
- session->nmem = nmem_create();
- session->wrbuf = wrbuf_alloc();
- for (i = 0; i <= SESSION_WATCH_MAX; i++)
- {
- session->watchlist[i].data = 0;
- session->watchlist[i].fun = 0;
- }
-
- select_targets(session);
-
- return session;
-}
-
-struct hitsbytarget *hitsbytarget(struct session *se, int *count)
-{
- static struct hitsbytarget res[1000]; // FIXME MM
- struct client *cl;
-
- *count = 0;
- for (cl = se->clients; cl; cl = cl->next)
- {
- res[*count].id = cl->database->url;
- res[*count].name = cl->database->name;
- res[*count].hits = cl->hits;
- res[*count].records = cl->records;
- res[*count].diagnostic = cl->diagnostic;
- res[*count].state = client_states[cl->state];
- res[*count].connected = cl->connection ? 1 : 0;
- (*count)++;
- }
-
- return res;
-}
-
-struct termlist_score **termlist(struct session *s, const char *name, int *num)
-{
- int i;
-
- for (i = 0; i < s->num_termlists; i++)
- if (!strcmp(s->termlists[i].name, name))
- return termlist_highscore(s->termlists[i].termlist, num);
- return 0;
-}
-
-#ifdef MISSING_HEADERS
-void report_nmem_stats(void)
-{
- size_t in_use, is_free;
-
- nmem_get_memory_in_use(&in_use);
- nmem_get_memory_free(&is_free);
-
- yaz_log(YLOG_LOG, "nmem stat: use=%ld free=%ld",
- (long) in_use, (long) is_free);
-}
-#endif
-
-struct record_cluster *show_single(struct session *s, int id)
-{
- struct record_cluster *r;
-
- reclist_rewind(s->reclist);
- while ((r = reclist_read_record(s->reclist)))
- if (r->recid == id)
- return r;
- return 0;
-}
-
-struct record_cluster **show(struct session *s, struct reclist_sortparms *sp, int start,
- int *num, int *total, int *sumhits, NMEM nmem_show)
-{
- struct record_cluster **recs = nmem_malloc(nmem_show, *num
- * sizeof(struct record_cluster *));
- struct reclist_sortparms *spp;
- int i;
-#if USE_TIMING
- yaz_timing_t t = yaz_timing_create();
-#endif
-
- for (spp = sp; spp; spp = spp->next)
- if (spp->type == Metadata_sortkey_relevance)
- {
- relevance_prepare_read(s->relevance, s->reclist);
- break;
- }
- reclist_sort(s->reclist, sp);
-
- *total = s->reclist->num_records;
- *sumhits = s->total_hits;
-
- for (i = 0; i < start; i++)
- if (!reclist_read_record(s->reclist))
- {
- *num = 0;
- recs = 0;
- break;
- }
-
- for (i = 0; i < *num; i++)