* Copyright (C) 1995-2006, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: zoom-c.c,v 1.92 2006-10-05 14:58:58 adam Exp $
+ * $Id: zoom-c.c,v 1.93 2006-10-26 15:34:46 adam Exp $
*/
/**
* \file zoom-c.c
{
case ZOOM_TASK_SEARCH:
ZOOM_resultset_destroy(task->u.search.resultset);
+ xfree(task->u.search.syntax);
+ xfree(task->u.search.elementSetName);
break;
case ZOOM_TASK_RETRIEVE:
ZOOM_resultset_destroy(task->u.retrieve.resultset);
+ xfree(task->u.retrieve.syntax);
+ xfree(task->u.retrieve.elementSetName);
break;
case ZOOM_TASK_CONNECT:
break;
ZOOM_connection_remove_task(c);
}
-static ZOOM_record record_cache_lookup(ZOOM_resultset r, int pos);
+static ZOOM_record record_cache_lookup(ZOOM_resultset r, int pos,
+ const char *syntax,
+ const char *elementSetName);
ZOOM_API(ZOOM_connection)
ZOOM_connection_create(ZOOM_options options)
ZOOM_task task;
const char *cp;
int start, count;
+ const char *syntax, *elementSetName;
yaz_log(log_api, "%p ZOOM_connection_search set %p query %p", c, r, q);
r->r_sort_spec = q->sort_spec;
task->u.search.resultset = r;
task->u.search.start = start;
task->u.search.count = count;
- ZOOM_resultset_addref(r);
+
+ syntax = ZOOM_options_get(r->options, "preferredRecordSyntax");
+ task->u.search.syntax = syntax ? xstrdup(syntax) : 0;
+ elementSetName = ZOOM_options_get(r->options, "elementSetName");
+ task->u.search.elementSetName = elementSetName
+ ? xstrdup(elementSetName) : 0;
+
+ ZOOM_resultset_addref(r);
(q->refcount)++;
ZOOM_task task;
ZOOM_connection c;
const char *cp;
+ const char *syntax, *elementSetName;
if (!r)
return;
task->u.retrieve.start = start;
task->u.retrieve.count = count;
+ syntax = ZOOM_options_get(r->options, "preferredRecordSyntax");
+ task->u.retrieve.syntax = syntax ? xstrdup(syntax) : 0;
+ elementSetName = ZOOM_options_get(r->options, "elementSetName");
+ task->u.retrieve.elementSetName = elementSetName
+ ? xstrdup(elementSetName) : 0;
+
cp = ZOOM_options_get(r->options, "schema");
if (cp)
{
odr_prepend(c->odr_out, "ZOOM-C",
ireq->implementationName));
- version = odr_strdup(c->odr_out, "$Revision: 1.92 $");
+ version = odr_strdup(c->odr_out, "$Revision: 1.93 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
ireq->implementationVersion =
if (c->error) /* don't continue on error */
return zoom_complete;
assert(c->tasks);
- if (c->tasks->which == ZOOM_TASK_SEARCH)
+ switch(c->tasks->which)
{
+ case ZOOM_TASK_SEARCH:
resultset = c->tasks->u.search.resultset;
resultset->setname = xstrdup("default");
ZOOM_options_set(resultset->options, "setname", resultset->setname);
start = &c->tasks->u.search.start;
count = &c->tasks->u.search.count;
- }
- else if (c->tasks->which == ZOOM_TASK_RETRIEVE)
- {
+ break;
+ case ZOOM_TASK_RETRIEVE:
resultset = c->tasks->u.retrieve.resultset;
start = &c->tasks->u.retrieve.start;
for (i = 0; i < *count; i++)
{
ZOOM_record rec =
- record_cache_lookup(resultset, i + *start);
+ record_cache_lookup(resultset, i + *start,
+ c->tasks->u.retrieve.syntax,
+ c->tasks->u.retrieve.elementSetName);
if (!rec)
break;
else
if (*count == 0)
return zoom_complete;
+ break;
+ default:
+ return zoom_complete;
}
assert(resultset->query);
set_DatabaseNames(c, r->options, &search_req->num_databaseNames);
/* get syntax (no need to provide unless piggyback is in effect) */
- syntax = ZOOM_options_get(r->options, "preferredRecordSyntax");
+ syntax = c->tasks->u.search.syntax;
lslb = ZOOM_options_get_int(r->options, "largeSetLowerBound", -1);
ssub = ZOOM_options_get_int(r->options, "smallSetUpperBound", -1);
ZOOM_API(ZOOM_record)
ZOOM_resultset_record_immediate(ZOOM_resultset s,size_t pos)
{
- return record_cache_lookup(s, pos);
+ const char *syntax =
+ ZOOM_options_get(s->options, "preferredRecordSyntax");
+ const char *elementSetName =
+ ZOOM_options_get(s->options, "elementSetName");
+
+ return record_cache_lookup(s, pos, syntax, elementSetName);
}
ZOOM_API(ZOOM_record)
}
static void record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr,
- int pos)
+ int pos,
+ const char *syntax, const char *elementSetName)
{
ZOOM_record_cache rc;
- const char *elementSetName =
- ZOOM_resultset_option_get(r, "elementSetName");
- const char *syntax =
- ZOOM_resultset_option_get(r, "preferredRecordSyntax");
ZOOM_Event event = ZOOM_Event_create(ZOOM_EVENT_RECV_RECORD);
ZOOM_connection_put_event(r->connection, event);
r->record_hash[record_hash(pos)] = rc;
}
-static ZOOM_record record_cache_lookup(ZOOM_resultset r, int pos)
+static ZOOM_record record_cache_lookup(ZOOM_resultset r, int pos,
+ const char *syntax,
+ const char *elementSetName)
{
ZOOM_record_cache rc;
- const char *elementSetName =
- ZOOM_resultset_option_get(r, "elementSetName");
- const char *syntax =
- ZOOM_resultset_option_get(r, "preferredRecordSyntax");
for (rc = r->record_hash[record_hash(pos)]; rc; rc = rc->next)
{
{
ZOOM_resultset resultset;
int *start, *count;
+ const char *syntax = 0, *elementSetName = 0;
if (!c->tasks)
return ;
resultset = c->tasks->u.search.resultset;
start = &c->tasks->u.search.start;
count = &c->tasks->u.search.count;
+ syntax = c->tasks->u.search.syntax;
+ elementSetName = c->tasks->u.search.elementSetName;
break;
case ZOOM_TASK_RETRIEVE:
resultset = c->tasks->u.retrieve.resultset;
start = &c->tasks->u.retrieve.start;
count = &c->tasks->u.retrieve.count;
+ syntax = c->tasks->u.retrieve.syntax;
+ elementSetName = c->tasks->u.retrieve.elementSetName;
break;
default:
return;
sr->u.databaseOrSurDiagnostics;
for (i = 0; i<p->num_records; i++)
{
- record_cache_add(resultset, p->records[i], i + *start);
+ record_cache_add(resultset, p->records[i], i + *start,
+ syntax, elementSetName);
}
*count -= i;
*start += i;
/* present response and we didn't get any records! */
Z_NamePlusRecord *myrec =
zget_surrogateDiagRec(resultset->odr, 0, 14, 0);
- record_cache_add(resultset, myrec, *start);
+ record_cache_add(resultset, myrec, *start,
+ syntax, elementSetName);
}
}
else if (present_phase)
/* present response and we didn't get any records! */
Z_NamePlusRecord *myrec =
zget_surrogateDiagRec(resultset->odr, 0, 14, 0);
- record_cache_add(resultset, myrec, *start);
+ record_cache_add(resultset, myrec, *start, syntax, elementSetName);
}
}
}
resultset = c->tasks->u.search.resultset;
start = &c->tasks->u.search.start;
count = &c->tasks->u.search.count;
+ syntax = c->tasks->u.search.syntax;
+ elementSetName = c->tasks->u.search.elementSetName;
break;
case ZOOM_TASK_RETRIEVE:
resultset = c->tasks->u.retrieve.resultset;
start = &c->tasks->u.retrieve.start;
count = &c->tasks->u.retrieve.count;
+ syntax = c->tasks->u.retrieve.syntax;
+ elementSetName = c->tasks->u.retrieve.elementSetName;
if (*start >= resultset->size)
{
yaz_log(log_details, "%p send_present start=%d count=%d",
c, *start, *count);
- syntax = ZOOM_resultset_option_get(resultset, "preferredRecordSyntax");
- elementSetName = ZOOM_resultset_option_get(resultset, "elementSetName");
-
if (c->error) /* don't continue on error */
return zoom_complete;
if (*start < 0)
for (i = 0; i < *count; i++)
{
ZOOM_record rec =
- record_cache_lookup(resultset, i + *start);
+ record_cache_lookup(resultset, i + *start, syntax, elementSetName);
if (!rec)
break;
else
NMEM nmem;
ZOOM_Event event;
int *start;
+ const char *syntax, *elementSetName;
if (!c->tasks)
return;
- if (c->tasks->which == ZOOM_TASK_SEARCH)
+ switch(c->tasks->which)
{
+ case ZOOM_TASK_SEARCH:
resultset = c->tasks->u.search.resultset;
start = &c->tasks->u.search.start;
- }
- else if (c->tasks->which == ZOOM_TASK_RETRIEVE)
- {
+ syntax = c->tasks->u.search.syntax;
+ elementSetName = c->tasks->u.search.elementSetName;
+ break;
+ case ZOOM_TASK_RETRIEVE:
resultset = c->tasks->u.retrieve.resultset;
start = &c->tasks->u.retrieve.start;
+ syntax = c->tasks->u.retrieve.syntax;
+ elementSetName = c->tasks->u.retrieve.elementSetName;
+ break;
+ default:
+ return;
}
- else
- return ;
-
event = ZOOM_Event_create(ZOOM_EVENT_RECV_SEARCH);
ZOOM_connection_put_event(c, event);
npr->u.databaseRecord->u.octet_aligned->len =
npr->u.databaseRecord->u.octet_aligned->size =
res->records[i].recordData_len;
- record_cache_add(resultset, npr, pos);
+ record_cache_add(resultset, npr, pos, syntax, elementSetName);
}
if (res->num_diagnostics > 0)
{