static zoom_ret do_write_ex(ZOOM_connection c, char *buf_out, int len_out);
static char *cql2pqf(ZOOM_connection c, const char *cql);
-const char *ZOOM_get_event_str(int event)
+ZOOM_API(const char *) ZOOM_get_event_str(int event)
{
static const char *ar[] = {
"NONE",
yaz_log(YLOG_LOG, "connect p=%p", task);
break;
case ZOOM_TASK_SCAN:
- yaz_log(YLOG_LOG, "scant p=%p", task);
+ yaz_log(YLOG_LOG, "scan p=%p", task);
break;
}
}
set_ZOOM_error(c, ZOOM_ERROR_NONE, 0);
ZOOM_connection_remove_tasks(c);
+ if (ZOOM_options_get_bool(c->options, "apdulog", 0))
+ {
+ c->odr_print = odr_createmem(ODR_PRINT);
+ odr_setprint(c->odr_print, yaz_log_file());
+ }
+ else
+ c->odr_print = 0;
+
if (c->cs)
{
yaz_log(log_details, "%p ZOOM_connection_connect reconnect ok", c);
ZOOM_options_get_int(c->options, "preferredMessageSize", 1024*1024);
c->async = ZOOM_options_get_bool(c->options, "async", 0);
- if (ZOOM_options_get_bool(c->options, "apdulog", 0))
- {
- c->odr_print = odr_createmem(ODR_PRINT);
- odr_setprint(c->odr_print, yaz_log_file());
- }
- else
- c->odr_print = 0;
yaz_log(log_details, "%p ZOOM_connection_connect async=%d", c, c->async);
task = ZOOM_connection_add_task(c, ZOOM_TASK_CONNECT);
task->u.search.resultset = r;
task->u.search.start = start;
task->u.search.count = count;
+ task->u.search.recv_search_fired = 0;
syntax = ZOOM_options_get(r->options, "preferredRecordSyntax");
task->u.search.syntax = syntax ? xstrdup(syntax) : 0;
{
Z_GDU *gdu;
ZOOM_Event event;
-
- gdu = z_get_HTTP_Request_host_path(c->odr_out, c->host_port, c->path);
+ const char *database = ZOOM_options_get(c->options, "databaseName");
+ char *fdatabase = 0;
+
+ if (database)
+ {
+ fdatabase = (char *) odr_malloc(c->odr_out, strlen(database)+2);
+ strcpy(fdatabase, "/");
+ strcat(fdatabase, database);
+ }
+ gdu = z_get_HTTP_Request_host_path(c->odr_out, c->host_port,
+ fdatabase ? fdatabase : c->path);
if (c->sru_mode == zoom_sru_get)
{
count = &c->tasks->u.search.count;
syntax = c->tasks->u.search.syntax;
elementSetName = c->tasks->u.search.elementSetName;
+
+ if (!c->tasks->u.search.recv_search_fired)
+ {
+ event = ZOOM_Event_create(ZOOM_EVENT_RECV_SEARCH);
+ ZOOM_connection_put_event(c, event);
+ c->tasks->u.search.recv_search_fired = 1;
+ }
break;
case ZOOM_TASK_RETRIEVE:
resultset = c->tasks->u.retrieve.resultset;
default:
return zoom_complete;
}
- event = ZOOM_Event_create(ZOOM_EVENT_RECV_SEARCH);
- ZOOM_connection_put_event(c, event);
resultset->size = 0;
ZOOM_resultset_option_set(resultset, "resultSetId", res->resultSetId);
yaz_log(log_details, "%p handle_srw_response got SRW response OK", c);
-
- if (res->numberOfRecords)
- resultset->size = *res->numberOfRecords;
- for (i = 0; i<res->num_records; i++)
+ if (res->num_diagnostics > 0)
{
- int pos;
- Z_SRW_record *sru_rec;
- Z_SRW_diagnostic *diag = 0;
- int num_diag;
-
- Z_NamePlusRecord *npr = (Z_NamePlusRecord *)
- odr_malloc(c->odr_in, sizeof(Z_NamePlusRecord));
-
- if (res->records[i].recordPosition &&
- *res->records[i].recordPosition > 0)
- pos = *res->records[i].recordPosition - 1;
- else
- pos = *start + i;
-
- sru_rec = &res->records[i];
-
- npr->databaseName = 0;
- npr->which = Z_NamePlusRecord_databaseRecord;
- npr->u.databaseRecord = (Z_External *)
- odr_malloc(c->odr_in, sizeof(Z_External));
- npr->u.databaseRecord->descriptor = 0;
- npr->u.databaseRecord->direct_reference =
- odr_oiddup(c->odr_in, yaz_oid_recsyn_xml);
- npr->u.databaseRecord->which = Z_External_octet;
-
- npr->u.databaseRecord->u.octet_aligned = (Odr_oct *)
- odr_malloc(c->odr_in, sizeof(Odr_oct));
- npr->u.databaseRecord->u.octet_aligned->buf = (unsigned char*)
- sru_rec->recordData_buf;
- npr->u.databaseRecord->u.octet_aligned->len =
- npr->u.databaseRecord->u.octet_aligned->size =
- sru_rec->recordData_len;
-
- if (sru_rec->recordSchema
- && !strcmp(sru_rec->recordSchema,
- "info:srw/schema/1/diagnostics-v1.1"))
+ set_SRU_error(c, &res->diagnostics[0]);
+ }
+ else
+ {
+ if (res->numberOfRecords)
+ resultset->size = *res->numberOfRecords;
+ for (i = 0; i<res->num_records; i++)
{
- sru_decode_surrogate_diagnostics(sru_rec->recordData_buf,
- sru_rec->recordData_len,
- &diag, &num_diag,
- resultset->odr);
+ int pos;
+ Z_SRW_record *sru_rec;
+ Z_SRW_diagnostic *diag = 0;
+ int num_diag;
+
+ Z_NamePlusRecord *npr = (Z_NamePlusRecord *)
+ odr_malloc(c->odr_in, sizeof(Z_NamePlusRecord));
+
+ if (res->records[i].recordPosition &&
+ *res->records[i].recordPosition > 0)
+ pos = *res->records[i].recordPosition - 1;
+ else
+ pos = *start + i;
+
+ sru_rec = &res->records[i];
+
+ npr->databaseName = 0;
+ npr->which = Z_NamePlusRecord_databaseRecord;
+ npr->u.databaseRecord = (Z_External *)
+ odr_malloc(c->odr_in, sizeof(Z_External));
+ npr->u.databaseRecord->descriptor = 0;
+ npr->u.databaseRecord->direct_reference =
+ odr_oiddup(c->odr_in, yaz_oid_recsyn_xml);
+ npr->u.databaseRecord->which = Z_External_octet;
+
+ npr->u.databaseRecord->u.octet_aligned = (Odr_oct *)
+ odr_malloc(c->odr_in, sizeof(Odr_oct));
+ npr->u.databaseRecord->u.octet_aligned->buf = (unsigned char*)
+ sru_rec->recordData_buf;
+ npr->u.databaseRecord->u.octet_aligned->len =
+ npr->u.databaseRecord->u.octet_aligned->size =
+ sru_rec->recordData_len;
+
+ if (sru_rec->recordSchema
+ && !strcmp(sru_rec->recordSchema,
+ "info:srw/schema/1/diagnostics-v1.1"))
+ {
+ sru_decode_surrogate_diagnostics(sru_rec->recordData_buf,
+ sru_rec->recordData_len,
+ &diag, &num_diag,
+ resultset->odr);
+ }
+ record_cache_add(resultset, npr, pos, syntax, elementSetName,
+ sru_rec->recordSchema, diag);
}
- record_cache_add(resultset, npr, pos, syntax, elementSetName,
- sru_rec->recordSchema, diag);
- }
- *count -= i;
- *start += i;
- if (*count + *start > resultset->size)
- *count = resultset->size - *start;
- if (*count < 0)
- *count = 0;
+ *count -= i;
+ *start += i;
+ if (*count + *start > resultset->size)
+ *count = resultset->size - *start;
+ if (*count < 0)
+ *count = 0;
+
+ nmem = odr_extract_mem(c->odr_in);
+ nmem_transfer(odr_getmem(resultset->odr), nmem);
+ nmem_destroy(nmem);
- nmem = odr_extract_mem(c->odr_in);
- nmem_transfer(odr_getmem(resultset->odr), nmem);
- nmem_destroy(nmem);
-
- if (res->num_diagnostics > 0)
- set_SRU_error(c, &res->diagnostics[0]);
- else if (*count > 0)
- return ZOOM_connection_srw_send_search(c);
+ if (*count > 0)
+ return ZOOM_connection_srw_send_search(c);
+ }
return zoom_complete;
}
#endif