* Copyright (c) 1995-2004, Index Data
* See the file LICENSE for details.
*
- * $Id: seshigh.c,v 1.22 2004-03-16 13:12:43 adam Exp $
+ * $Id: seshigh.c,v 1.31 2004-09-30 21:51:59 adam Exp $
*/
/*
ce = yaz_set_proposal_charneg(assoc->decode, &encoding, 1, 0, 0, 1);
assoc->init->charneg_request = ce->u.charNeg3;
#endif
+ assoc->backend = 0;
if (!(binitres = (*cb->bend_init)(assoc->init)))
{
yaz_log(LOG_WARN, "Bad response from backend.");
rr.comp->u.complex->generic = (Z_Specification *)
odr_malloc(assoc->decode, sizeof(Z_Specification));
+
+ /* schema uri = recordSchema (or NULL if recordSchema is not given) */
rr.comp->u.complex->generic->which = Z_Schema_uri;
rr.comp->u.complex->generic->schema.uri = srw_req->recordSchema;
+
+ /* ESN = recordSchema if recordSchema is present */
rr.comp->u.complex->generic->elementSpec = 0;
+ if (srw_req->recordSchema)
+ {
+ rr.comp->u.complex->generic->elementSpec =
+ (Z_ElementSpec *) odr_malloc(assoc->encode, sizeof(Z_ElementSpec));
+ rr.comp->u.complex->generic->elementSpec->which =
+ Z_ElementSpec_elementSetName;
+ rr.comp->u.complex->generic->elementSpec->u.elementSetName =
+ srw_req->recordSchema;
+ }
rr.stream = assoc->encode;
rr.print = assoc->print;
(*assoc->init->bend_fetch)(assoc->backend, &rr);
- if (rr.len >= 0)
+ if (rr.errcode && rr.surrogate_flag)
+ {
+ int code = yaz_diag_bib1_to_srw(rr.errcode);
+ const char *message = yaz_diag_srw_str(code);
+ int len = 120;
+ if (message)
+ len += strlen(message);
+ if (rr.errstring)
+ len += strlen(rr.errstring);
+
+ record->recordData_buf = odr_malloc(o, len);
+
+ sprintf(record->recordData_buf, "<diagnostic>\n"
+ " <uri>info:srw/diagnostic/1/%d</uri>\n", code);
+ if (rr.errstring)
+ sprintf(record->recordData_buf + strlen(record->recordData_buf),
+ " <details>%s</details>\n", rr.errstring);
+ if (message)
+ sprintf(record->recordData_buf + strlen(record->recordData_buf),
+ " <message>%s</message>\n", message);
+ sprintf(record->recordData_buf + strlen(record->recordData_buf),
+ "</diagnostic>\n");
+ record->recordData_len = strlen(record->recordData_buf);
+ record->recordPosition = odr_intdup(o, pos);
+ record->recordSchema = "info:srw/schema/1/diagnostics-v1.1";
+ return 0;
+ }
+ else if (rr.len >= 0)
{
record->recordData_buf = rr.record;
record->recordData_len = rr.len;
const char *pqf_msg;
size_t off;
int code = yaz_pqf_error (pqf_parser, &pqf_msg, &off);
- yaz_log(LOG_LOG, "%*s^\n", off+4, "");
+ if (off < 200)
+ yaz_log(LOG_LOG, "%*s^\n", (int)off+4, "");
yaz_log(LOG_LOG, "Bad PQF: %s (code %d)\n", pqf_msg, code);
srw_error = 10;
rr.search_info = 0;
yaz_log_zquery(rr.query);
(assoc->init->bend_search)(assoc->backend, &rr);
- srw_res->numberOfRecords = odr_intdup(assoc->encode, rr.hits);
if (rr.errcode)
{
yaz_log(LOG_DEBUG, "bend_search returned Bib-1 code %d", rr.errcode);
if (start > rr.hits)
{
- yaz_log(LOG_LOG, "Request out or range");
+ srw_res->num_diagnostics = 1;
+ srw_res->diagnostics = (Z_SRW_diagnostic *)
+ odr_malloc(assoc->encode,
+ sizeof(*srw_res->diagnostics));
+ yaz_mk_std_diagnostic(assoc->encode, srw_res->diagnostics,
+ 61, 0);
}
else
{
if (srw_req->recordPacking &&
!strcmp(srw_req->recordPacking, "xml"))
packing = Z_SRW_recordPacking_XML;
- srw_res->record.recordSchema = 0;
+ srw_res->record.recordSchema = rr.schema;
srw_res->record.recordPacking = packing;
srw_res->record.recordData_buf = rr.explain_buf;
srw_res->record.recordData_len = strlen(rr.explain_buf);
return -1;
}
break;
+ case Z_APDU_triggerResourceControlRequest:
+ return 0;
default:
*msg = "Bad APDU received";
return -1;
assoc->init->charneg_request = negotiation;
}
+ assoc->backend = 0;
if (!(binitres = (*cb->bend_init)(assoc->init)))
{
yaz_log(LOG_WARN, "Bad response from backend.");
ODR_MASK_SET(resp->options, Z_Options_negotiationModel);
strcat(options, " negotiation");
}
+
+ ODR_MASK_SET(resp->options, Z_Options_triggerResourceCtrl);
if (ODR_MASK_GET(req->protocolVersion, Z_ProtocolVersion_1))
{
assoc->init->implementation_name,
odr_prepend(assoc->encode, "GFS", resp->implementationName));
- version = odr_strdup(assoc->encode, "$Revision: 1.22 $");
+ version = odr_strdup(assoc->encode, "$Revision: 1.31 $");
if (strlen(version) > 10) /* check for unexpanded CVS strings */
version[strlen(version)-2] = '\0';
resp->implementationVersion = odr_prepend(assoc->encode,
e->which = Z_DiagnosticFormat_s_defaultDiagRec;
e->u.defaultDiagRec = justdiag(odr, error, addinfo);
+ e->message = 0;
return x;
}
records->u.databaseOrSurDiagnostics = reclist;
reclist->num_records = 0;
reclist->records = list;
- *pres = Z_PRES_SUCCESS;
+ *pres = Z_PresentStatus_success;
*num = 0;
*next = 0;
if (!freq.surrogate_flag)
{
char s[20];
- *pres = Z_PRES_FAILURE;
+ *pres = Z_PresentStatus_failure;
/* for 'present request out of range',
set addinfo to record position if not set */
if (freq.errcode == 13 && freq.errstring == 0)
if (this_length <= a->preferredMessageSize && recno > start)
{
yaz_log(LOG_DEBUG, " Dropped last normal-sized record");
- *pres = Z_PRES_PARTIAL_2;
+ *pres = Z_PresentStatus_partial_2;
break;
}
/* record can only be fetched by itself */
int *nulint = odr_intdup (assoc->encode, 0);
bool_t *sr = odr_intdup(assoc->encode, 1);
int *next = odr_intdup(assoc->encode, 0);
- int *none = odr_intdup(assoc->encode, Z_RES_NONE);
+ int *none = odr_intdup(assoc->encode, Z_SearchResponse_none);
apdu->which = Z_APDU_searchResponse;
apdu->u.searchResponse = resp;
if (bprr->errcode)
{
resp->records = diagrec(assoc, bprr->errcode, bprr->errstring);
- *resp->presentStatus = Z_PRES_FAILURE;
+ *resp->presentStatus = Z_PresentStatus_failure;
}
}
apdu = (Z_APDU *)odr_malloc (assoc->encode, sizeof(*apdu));
bsrr->stream = assoc->encode;
bsrr->print = assoc->print;
- bsrr->sort_status = Z_SortStatus_failure;
+ bsrr->sort_status = Z_SortResponse_failure;
bsrr->errcode = 0;
bsrr->errstring = 0;