mt->subfield_pp = &n->u.datafield.subfields;
}
-// Magic function: adds a attribute value to the element name if it is plain characters.
-// if not, and if the attribute name is not null, it will append a attribute element with the value
-// if attribute name is null it will return a non-zero value meaning it couldnt handle the value.
-
+/** \brief adds a attribute value to the element name if it is plain chars
+
+ If not, and if the attribute name is not null, it will append a
+ attribute element with the value if attribute name is null it will
+ return a non-zero value meaning it couldnt handle the value.
+*/
static int element_name_append_attribute_value(
yaz_marc_t mt, WRBUF buffer,
const char *attribute_name, char *code_data, size_t code_len)
{
- // TODO Map special codes to something possible for XML ELEMENT names
+ /* TODO Map special codes to something possible for XML ELEMENT names */
int encode = 0;
int index = 0;
(code_data[index] >= 'A' && code_data[index] <= 'Z')))
encode = 1;
}
- // Add as attribute
+ /* Add as attribute */
if (encode && attribute_name)
wrbuf_printf(buffer, " %s=\"", attribute_name);
success = -1;
if (encode && attribute_name)
- wrbuf_printf(buffer, "\""); // return error if we couldn't handle it.
+ wrbuf_printf(buffer, "\""); /* return error if we couldn't handle it.*/
return success;
}
n->u.datafield.indicator = indicators;
n->u.datafield.subfields = 0;
- // make subfield_pp the current (last one)
+ /* make subfield_pp the current (last one) */
mt->subfield_pp = &n->u.datafield.subfields;
}
wrbuf_puts(wr, ">\n");
}
wrbuf_printf(wr, " </%s", datafield_name[turbo]);
- //TODO Not CDATA
+ /* TODO Not CDATA */
if (turbo)
wrbuf_iconv_write_cdata(wr, mt->iconv_cd, n->u.datafield.tag,
strlen(n->u.datafield.tag));
}
else
{
- //TODO convert special
+ /* TODO convert special */
wrbuf_iconv_write_cdata(wr, mt->iconv_cd, n->u.controlfield.tag,
strlen(n->u.controlfield.tag));
wrbuf_iconv_puts(wr, mt->iconv_cd, ">");
strlen(n->u.controlfield.data));
marc_iconv_reset(mt, wr);
wrbuf_printf(wr, "</%s", controlfield_name[turbo]);
- //TODO convert special
+ /* TODO convert special */
if (turbo)
wrbuf_iconv_write_cdata(wr, mt->iconv_cd, n->u.controlfield.tag,
strlen(n->u.controlfield.tag));
struct yaz_marc_subfield *s;
WRBUF subfield_name = wrbuf_alloc();
- //TODO consider if safe
+ /* TODO consider if safe */
char field[10];
field[0] = 'd';
strncpy(field + 1, n->u.datafield.tag, 3);
BAD_CAST wrbuf_cstr(wr_cdata));
if (not_written)
{
- // Generate code attribute value and add
+ /* Generate code attribute value and add */
wrbuf_rewind(wr_cdata);
wrbuf_iconv_write(wr_cdata, mt->iconv_cd,s->code_data, using_code_len);
xmlNewProp(ptr_subfield, BAD_CAST "code", BAD_CAST wrbuf_cstr(wr_cdata));
#endif
fd_set write_set;
- // create server socket
+ /* create server socket */
p->m_socket = socket(AF_INET, SOCK_STREAM, 0);
if (p->m_socket == YAZ_INVALID_SOCKET)
{
}
}
#endif
- // bind server socket
+ /* bind server socket */
add.sin_family = AF_INET;
add.sin_port = htons(port_to_use);
add.sin_addr.s_addr = INADDR_ANY;
return 0;
}
- // client socket
+ /* client socket */
tmpadd = (unsigned) inet_addr("127.0.0.1");
if (!tmpadd)
{
{
if (
#ifdef WIN32
- WSAGetLastError() != WSAEWOULDBLOCK
+ WSAGetLastError() != WSAEWOULDBLOCK
#else
- errno != EINPROGRESS
+ errno != EINPROGRESS
#endif
)
{
}
}
else if (o->direction == ODR_ENCODE)
- {
+ {
xmlNodePtr ptr = pptr;
add_xsd_string(ptr, "versionType", rec->versionType);
add_xsd_string(ptr, "versionValue", rec->versionValue);
{
int i;
for (i = 0; i < *num; i++)
- {
+ {
xmlNodePtr rptr = xmlNewChild(pptr, 0, BAD_CAST "version",
0);
yaz_srw_version(o, rptr, (*vers)+i, client_data, ns);
return 0;
}
-Z_FacetTerm *yaz_sru_proxy_get_facet_term_count(ODR odr, xmlNodePtr node) {
-
+Z_FacetTerm *yaz_sru_proxy_get_facet_term_count(ODR odr, xmlNodePtr node)
+{
int freq;
xmlNodePtr child;
WRBUF wrbuf = wrbuf_alloc();
for (child = node->children; child ; child = child->next) {
if (child->type == XML_TEXT_NODE)
- wrbuf_puts(wrbuf, (const char *) child->content);
+ wrbuf_puts(wrbuf, (const char *) child->content);
}
term = term_create(odr, wrbuf_cstr(wrbuf));
yaz_log(YLOG_DEBUG, "sru-proxy facet: %s %d", wrbuf_cstr(wrbuf), freq);
return facet_term_create(odr, term, freq);
};
-static Z_FacetField *yaz_sru_proxy_decode_facet_field(ODR odr, xmlNodePtr ptr) {
+static Z_FacetField *yaz_sru_proxy_decode_facet_field(ODR odr, xmlNodePtr ptr)
+{
Z_AttributeList *list;
Z_FacetField *facet_field;
int num_terms = 0;
int index = 0;
xmlNodePtr node;
- // USE attribute
+ /* USE attribute */
const char* name = yaz_element_attribute_value_get(ptr, "facet", "code");
yaz_log(YLOG_DEBUG, "sru-proxy facet type: %s", name);
}
facet_field = facet_field_create(odr, list, num_terms);
index = 0;
- for (node = ptr->children; node; node = node->next) {
- if (match_element(node, "facetvalue")) {
+ for (node = ptr->children; node; node = node->next)
+ {
+ if (match_element(node, "facetvalue"))
+ {
facet_field_term_set(odr, facet_field, yaz_sru_proxy_get_facet_term_count(odr, node), index);
- index++;
+ index++;
}
}
return facet_field;
}
-static int yaz_sru_proxy_decode_facets(ODR o, xmlNodePtr root, Z_FacetList **facetList)
+static int yaz_sru_proxy_decode_facets(ODR o, xmlNodePtr root,
+ Z_FacetList **facetList)
{
xmlNodePtr ptr;
*num = 0;
for (ptr = pptr; ptr; ptr = ptr->next)
{
- if (ptr->type == XML_ELEMENT_NODE &&
- !xmlStrcmp(ptr->name, BAD_CAST "diagnostic"))
- (*num)++;
+ if (ptr->type == XML_ELEMENT_NODE &&
+ !xmlStrcmp(ptr->name, BAD_CAST "diagnostic"))
+ (*num)++;
}
if (!*num)
return 1;
*recs = (Z_SRW_diagnostic *) odr_malloc(o, *num * sizeof(**recs));
for (i = 0; i < *num; i++)
- {
- (*recs)[i].uri = 0;
- (*recs)[i].details = 0;
- (*recs)[i].message = 0;
- }
+ {
+ (*recs)[i].uri = 0;
+ (*recs)[i].details = 0;
+ (*recs)[i].message = 0;
+ }
for (i = 0, ptr = pptr; ptr; ptr = ptr->next)
{
if (ptr->type == XML_ELEMENT_NODE &&
if (match_xsd_string(ptr, "value", o, &term->value))
;
else if (match_xsd_integer(ptr, "numberOfRecords", o,
- &term->numberOfRecords))
+ &term->numberOfRecords))
;
else if (match_xsd_string(ptr, "displayTerm", o,
&term->displayTerm))
&(*p)->srw_version))
;
else if (match_xsd_string(ptr, "query", o,
- &req->query.cql))
+ &req->query.cql))
req->query_type = Z_SRW_query_type_cql;
else if (match_xsd_string(ptr, "pQuery", o,
- &req->query.pqf))
+ &req->query.pqf))
req->query_type = Z_SRW_query_type_pqf;
else if (match_xsd_string(ptr, "xQuery", o,
- &req->query.xcql))
+ &req->query.xcql))
req->query_type = Z_SRW_query_type_xcql;
else if (match_xsd_integer(ptr, "startRecord", o,
&req->startRecord))
&req->sort.sortKeys))
req->sort_type = Z_SRW_sort_type_sort;
else if (match_xsd_string(ptr, "stylesheet", o,
- &req->stylesheet))
+ &req->stylesheet))
;
else if (match_xsd_string(ptr, "database", o,
- &req->database))
+ &req->database))
;
}
if (!req->query.cql && !req->query.pqf && !req->query.xcql)
&(*p)->extraResponseData_len))
;
else if (match_xsd_integer(ptr, "numberOfRecords", o,
- &res->numberOfRecords))
+ &res->numberOfRecords))
;
else if (match_xsd_string(ptr, "resultSetId", o,
&res->resultSetId))
for (; ptr; ptr = ptr->next)
{
if (match_xsd_string(ptr, "version", o,
- &(*p)->srw_version))
+ &(*p)->srw_version))
;
else if (match_xsd_XML_n(ptr, "extraResponseData", o,
&(*p)->extraResponseData_buf,
&req->stylesheet))
;
else if (match_xsd_string(ptr, "recordPacking", o,
- &req->recordPacking))
+ &req->recordPacking))
;
else if (match_xsd_string(ptr, "database", o,
- &req->database))
+ &req->database))
;
}
}
for (; ptr; ptr = ptr->next)
{
if (match_xsd_string(ptr, "version", o,
- &(*p)->srw_version))
+ &(*p)->srw_version))
;
else if (match_xsd_XML_n(ptr, "extraResponseData", o,
&(*p)->extraResponseData_buf,
&(*p)->extraResponseData_len))
;
else if (match_xsd_string(ptr, "scanClause", o,
- &req->scanClause.cql))
+ &req->scanClause.cql))
;
else if (match_xsd_string(ptr, "pScanClause", o,
&req->scanClause.pqf))
client_data, ns_ucp_str);
}
else if (match_xsd_string(ptr, "stylesheet", o,
- &req->stylesheet))
+ &req->stylesheet))
;
else if (match_xsd_string(ptr, "database", o,
- &req->database))
+ &req->database))
;
}
}
&(*p)->srw_version))
;
else if (match_xsd_string(ptr, "operationStatus", o,
- &res->operationStatus ))
+ &res->operationStatus ))
;
else if (match_xsd_string(ptr, "recordIdentifier", o,
&res->recordId))
cs_close(c->cs);
#if ZOOM_RESULT_LISTS
- // Remove the connection's usage of resultsets
+ /* Remove the connection's usage of resultsets */
list = c->resultsets;
while (list) {
ZOOM_resultsets removed = list;
}
static int es_response_taskpackage_update(ZOOM_connection c,
- Z_IUUpdateTaskPackage *utp)
+ Z_IUUpdateTaskPackage *utp)
{
- if (utp && utp->targetPart)
- {
- Z_IUTargetPart *targetPart = utp->targetPart;
- switch ( *targetPart->updateStatus ) {
- case Z_IUTargetPart_success:
- ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "success");
- break;
- case Z_IUTargetPart_partial:
- ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "partial");
- break;
- case Z_IUTargetPart_failure:
- ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "failure");
- if (targetPart->globalDiagnostics && targetPart->num_globalDiagnostics > 0)
- response_diag(c, targetPart->globalDiagnostics[0]);
- break;
- }
- // NOTE: Individual record status, surrogate diagnostics, and supplemental diagnostics ARE NOT REPORTED.
- }
+ if (utp && utp->targetPart)
+ {
+ Z_IUTargetPart *targetPart = utp->targetPart;
+ switch ( *targetPart->updateStatus ) {
+ case Z_IUTargetPart_success:
+ ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "success");
+ break;
+ case Z_IUTargetPart_partial:
+ ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "partial");
+ break;
+ case Z_IUTargetPart_failure:
+ ZOOM_options_set(c->tasks->u.package->options,"updateStatus", "failure");
+ if (targetPart->globalDiagnostics && targetPart->num_globalDiagnostics > 0)
+ response_diag(c, targetPart->globalDiagnostics[0]);
+ break;
+ }
+ /* NOTE: Individual record status, surrogate diagnostics, and supplemental diagnostics ARE NOT REPORTED. */
+ }
return 1;
}
static int es_response_taskpackage(ZOOM_connection c,
Z_TaskPackage *taskPackage)
{
- // targetReference
- Odr_oct *id = taskPackage->targetReference;
- if (id)
- ZOOM_options_setl(c->tasks->u.package->options,
- "targetReference", (char*) id->buf, id->len);
-
- // taskStatus
- switch ( *taskPackage->taskStatus ) {
- case Z_TaskPackage_pending:
- ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "pending");
- break;
- case Z_TaskPackage_active:
- ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "active");
- break;
- case Z_TaskPackage_complete:
- ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "complete");
- break;
- case Z_TaskPackage_aborted:
- ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "aborted");
- if ( taskPackage->num_packageDiagnostics && taskPackage->packageDiagnostics )
- response_diag(c, taskPackage->packageDiagnostics[0]);
- break;
- }
-
- // taskSpecificParameters
- // NOTE: Only Update implemented, no others.
- if ( taskPackage->taskSpecificParameters->which == Z_External_update ) {
- Z_IUUpdateTaskPackage *utp = taskPackage->taskSpecificParameters->u.update->u.taskPackage;
- es_response_taskpackage_update(c, utp);
- }
- return 1;
+ Odr_oct *id = taskPackage->targetReference;
+ if (id)
+ ZOOM_options_setl(c->tasks->u.package->options,
+ "targetReference", (char*) id->buf, id->len);
+
+ switch ( *taskPackage->taskStatus ) {
+ case Z_TaskPackage_pending:
+ ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "pending");
+ break;
+ case Z_TaskPackage_active:
+ ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "active");
+ break;
+ case Z_TaskPackage_complete:
+ ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "complete");
+ break;
+ case Z_TaskPackage_aborted:
+ ZOOM_options_set(c->tasks->u.package->options,"taskStatus", "aborted");
+ if ( taskPackage->num_packageDiagnostics && taskPackage->packageDiagnostics )
+ response_diag(c, taskPackage->packageDiagnostics[0]);
+ break;
+ }
+ /* NOTE: Only Update implemented, no others. */
+ if ( taskPackage->taskSpecificParameters->which == Z_External_update )
+ {
+ Z_IUUpdateTaskPackage *utp = taskPackage->taskSpecificParameters->u.update->u.taskPackage;
+ es_response_taskpackage_update(c, utp);
+ }
+ return 1;
}
{
if (!c->tasks || c->tasks->which != ZOOM_TASK_PACKAGE)
return 0;
- switch (*res->operationStatus) {
- case Z_ExtendedServicesResponse_done:
- ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "done");
- break;
- case Z_ExtendedServicesResponse_accepted:
- ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "accepted");
- break;
- case Z_ExtendedServicesResponse_failure:
- ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "failure");
- if (res->diagnostics && res->num_diagnostics > 0)
- response_diag(c, res->diagnostics[0]);
- break;
+ switch (*res->operationStatus)
+ {
+ case Z_ExtendedServicesResponse_done:
+ ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "done");
+ break;
+ case Z_ExtendedServicesResponse_accepted:
+ ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "accepted");
+ break;
+ case Z_ExtendedServicesResponse_failure:
+ ZOOM_options_set(c->tasks->u.package->options,"operationStatus", "failure");
+ if (res->diagnostics && res->num_diagnostics > 0)
+ response_diag(c, res->diagnostics[0]);
+ break;
}
if (res->taskPackage &&
res->taskPackage->which == Z_External_extendedService)