+--- 4.1.7 2011/03/15
+
+Add -lCrun when linking with ICU on Solaris.
+
+More quicks character set conversions for OPAC records.
+
+--- 4.1.6 2011/03/10
+
+fix problem with record_render: records were converted (character set
+wise) even if no charset was given. Problem introduced in YAZ 4.1.5.
+
+--- 4.1.5 2011/03/08
+
+SRU: add methods for handling DADS SRU-proxy facets.
+
+Separate OPAC record character set for ZOOM_record. yaz_record_render
+allows a character set given as charset=from/opacfrom,to where 'from' is
+the character set of a bibliographic record, 'opacfrom' is character set
+of OPAC record and 'to' is the target character set.
+
--- 4.1.4 2011/02/21
yaz-client: show may XML format records. Command show followed by 'format'
dnl This file is part of the YAZ toolkit.
dnl Copyright (C) 1995-2011 Index Data
AC_PREREQ([2.60])
-AC_INIT([yaz],[4.1.4],[yaz-help@indexdata.dk])
+AC_INIT([yaz],[4.1.7],[yaz-help@indexdata.dk])
AC_CONFIG_HEADERS(include/config.h)
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_AUX_DIR([config])
+yaz (4.1.7-1indexdata) unstable; urgency=low
+
+ * Upstream.
+
+ -- Adam Dickmeiss <adam@indexdata.dk> Tue, 15 Mar 2011 13:59:18 +0100
+
+yaz (4.1.6-1indexdata) unstable; urgency=low
+
+ * Upstream.
+
+ -- Adam Dickmeiss <adam@indexdata.dk> Thu, 10 Mar 2011 10:25:48 +0100
+
+yaz (4.1.5-1indexdata) unstable; urgency=low
+
+ * Upstream.
+
+ -- Adam Dickmeiss <adam@indexdata.dk> Tue, 08 Mar 2011 13:53:17 +0100
+
yaz (4.1.4-1indexdata) unstable; urgency=low
* Upstream.
dh_fixperms
# dh_perl
# dh_python
- dh_makeshlibs -V 'libyaz4 (>= 4.1.0)'
+ dh_makeshlibs -V 'libyaz4 (>= 4.1.5)'
dh_installdeb
dh_shlibdeps -l debian/libyaz4/usr/lib
dh_gencontrol
<refsynopsisdiv>
<cmdsynopsis>
<command>yaz-icu</command>
- <arg choice="opt" rep="repeat">commands</arg>
<arg>-c <replaceable>config</replaceable></arg>
<arg>-p <replaceable>opt</replaceable></arg>
<arg>-s</arg>
<arg>-x</arg>
+ <arg choice="opt">infile</arg>
</cmdsynopsis>
</refsynopsisdiv>
<command>yaz-icu</command> is utility which demonstrates
the ICU chain module of yaz. (<filename>yaz/icu.h</filename>).
</para>
+ <para>
+ The utility can be used in two ways. It may read some text
+ using an XML configuration for configuring ICU and show text analysis.
+ This mode is triggered by option <literal>-c</literal> which specififies
+ the configuration to be used. The input file is read from standard
+ input or from a file if <literal>infile</literal> is specified.
+ </para>
+ <para>
+ The utility may also show ICU information. This is triggered by
+ option <literal>-p</literal>.
+ </para>
</refsect1>
<refsect1><title>OPTIONS</title>
#define ODR_MASK_SET(mask, num)\
(((mask)->bits[(num) >> 3] |= 0X80 >> ((num) & 0X07)),\
- (mask)->top < (num) >> 3 ? ((mask)->top = (num) >> 3) : 0)
+ (void) ((mask)->top < (num) >> 3 ? ((mask)->top = (num) >> 3) : 0))
#define ODR_MASK_CLEAR(mask, num)\
((mask)->bits[(num) >> 3] &= ~(0X80 >> ((num) & 0X07)))
__attribute__ ((format (printf, 2, 3)))
#endif
;
+
+/** \brief general writer of string using iconv and cdata
+ \param b WRBUF
+ \param cd iconv handle (0 for no conversion)
+ \param buf buffer
+ \param size size of buffer
+ \param cdata non-zero for CDATA; 0 for cdata
+ \returns -1 if invalid sequence was encountered (truncation in effect)
+ \returns 0 if buffer could be converted and written
+*/
+int wrbuf_iconv_write_x(WRBUF b, yaz_iconv_t cd, const char *buf,
+ size_t size, int cdata);
+
/** \brief iconv converts buffer and appends to WRBUF
\param b WRBUF
\param cd iconv handle
YAZ_EXPORT const char *wrbuf_cstr(WRBUF b);
#define wrbuf_putc(b, c) \
- (((b)->pos >= (b)->size ? wrbuf_grow(b, 1) : 0), \
+ ((void) ((b)->pos >= (b)->size ? wrbuf_grow(b, 1) : 0), \
(b)->buf[(b)->pos++] = (c), 0)
YAZ_END_CDECL
#define ZOOM_ERROR_CQL_TRANSFORM 10012
#define ZOOM_ERROR_CCL_CONFIG 10013
#define ZOOM_ERROR_CCL_PARSE 10014
+#define ZOOM_ERROR_ES_INVALID_ACTION 10015
+#define ZOOM_ERROR_ES_INVALID_VERSION 10016
+#define ZOOM_ERROR_ES_INVALID_SYNTAX 10017
ZOOM_API(int)
ZOOM_connection_last_event(ZOOM_connection cs);
-Subproject commit f7d7eb4b44b7fdad1942e32856d6afc2e6dcabda
+Subproject commit 96ff03f91b4539e315dadd50ab2564412c076394
if (ae->which == Z_AttributeValue_complex)
{
s = stringattr(ae->value.complex);
- yaz_log(YLOG_DEBUG, "useattr %s %s", s, av->useattr);
if (s)
{
if (!av->useattr)
if (ae->which == Z_AttributeValue_numeric)
{
av->limit = *ae->value.numeric;
- yaz_log(YLOG_DEBUG, "limitattr %d ", av->limit);
}
else
{
{
int i;
Z_AttributeElement *ae;
- yaz_log(YLOG_DEBUG, "Attribute num attributes: %d",
- attributes->num_attributes);
for (i=0; i < attributes->num_attributes; i++) {
ae = attributes->attributes[i];
/* ignoring the attributeSet here */
- yaz_log(YLOG_DEBUG, "Attribute type %d", (int) *ae->attributeType);
if (*ae->attributeType == 1)
{ /* use attribute */
useattr(ae, av);
sprintf(av->useattrbuff, ODR_INT_PRINTF,
*ae-> attributeType);
av->errstring = av->useattrbuff;
- yaz_log(YLOG_DEBUG, "Unsupported attribute type %s", av->useattrbuff);
+ yaz_log(YLOG_WARN, "Unsupported attribute type %s", av->useattrbuff);
/* would like to give a better message, but the standard */
/* tells me to return the attribute type */
}
transform->trans = 0;
if (id)
- {
icu_utf16_from_utf8_cstr(id16, id, status);
- id16->utf16[id16->utf16_len] = 0;
- }
+
if (rules)
icu_utf16_from_utf8_cstr(rules16, rules, status);
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.
-
-int element_name_append_attribute_value(yaz_marc_t mt, WRBUF buffer, const char *attribute_name, char *code_data, size_t code_len)
+/** \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));
#include <yaz/proto.h>
#include <yaz/marcdisp.h>
-static void opac_element_str(WRBUF wrbuf, yaz_iconv_t cd,
+static void opac_element_str(WRBUF wrbuf, yaz_iconv_t cd1, yaz_iconv_t cd2,
int l, const char *elem,
const char *data)
{
if (data)
{
+ size_t pos;
while (--l >= 0)
wrbuf_puts(wrbuf, " ");
wrbuf_puts(wrbuf, "<");
wrbuf_puts(wrbuf, elem);
wrbuf_puts(wrbuf, ">");
- wrbuf_iconv_puts_cdata(wrbuf, cd, data);
+
+ pos = wrbuf->pos; /* save position */
+ if (wrbuf_iconv_write_x(wrbuf, cd1, data, strlen(data), 1) && cd2)
+ {
+ wrbuf->pos = pos; /* rewind to pos */
+ wrbuf_iconv_write_x(wrbuf, cd2, data, strlen(data), 1);
+ }
wrbuf_puts(wrbuf, "</");
wrbuf_puts(wrbuf, elem);
wrbuf_puts(wrbuf, ">\n");
}
void yaz_opac_decode_wrbuf2(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf,
- yaz_iconv_t cd)
+ yaz_iconv_t cd2)
{
int i;
+ yaz_iconv_t cd1 = yaz_marc_get_iconv(mt);
wrbuf_puts(wrbuf, "<opacRecord>\n");
if (r->bibliographicRecord)
Z_HoldingsAndCircData *d = h->u.holdingsAndCirc;
- opac_element_str(wrbuf, cd, 2, "typeOfRecord", d->typeOfRecord);
- opac_element_str(wrbuf, cd, 2, "encodingLevel", d->encodingLevel);
- opac_element_str(wrbuf, cd, 2, "format", d->format);
- opac_element_str(wrbuf, cd, 2, "receiptAcqStatus", d->receiptAcqStatus);
- opac_element_str(wrbuf, cd, 2, "generalRetention", d->generalRetention);
- opac_element_str(wrbuf, cd, 2, "completeness", d->completeness);
- opac_element_str(wrbuf, cd, 2, "dateOfReport", d->dateOfReport);
- opac_element_str(wrbuf, cd, 2, "nucCode", d->nucCode);
- opac_element_str(wrbuf, cd, 2, "localLocation", d->localLocation);
- opac_element_str(wrbuf, cd, 2, "shelvingLocation", d->shelvingLocation);
- opac_element_str(wrbuf, cd, 2, "callNumber", d->callNumber);
- opac_element_str(wrbuf, cd, 2, "shelvingData", d->shelvingData);
-
- opac_element_str(wrbuf, cd, 2, "copyNumber", d->copyNumber);
- opac_element_str(wrbuf, cd, 2, "publicNote", d->publicNote);
- opac_element_str(wrbuf, cd, 2, "reproductionNote", d->reproductionNote);
- opac_element_str(wrbuf, cd, 2, "termsUseRepro", d->termsUseRepro);
- opac_element_str(wrbuf, cd, 2, "enumAndChron", d->enumAndChron);
+ opac_element_str(wrbuf, cd1, cd2, 2, "typeOfRecord",
+ d->typeOfRecord);
+ opac_element_str(wrbuf, cd1, cd2, 2, "encodingLevel",
+ d->encodingLevel);
+ opac_element_str(wrbuf, cd1, cd2, 2, "format",
+ d->format);
+ opac_element_str(wrbuf, cd1, cd2, 2, "receiptAcqStatus",
+ d->receiptAcqStatus);
+ opac_element_str(wrbuf, cd1, cd2, 2, "generalRetention",
+ d->generalRetention);
+ opac_element_str(wrbuf, cd1, cd2, 2, "completeness",
+ d->completeness);
+ opac_element_str(wrbuf, cd1, cd2, 2, "dateOfReport",
+ d->dateOfReport);
+ opac_element_str(wrbuf, cd1, cd2, 2, "nucCode", d->nucCode);
+ opac_element_str(wrbuf, cd1, cd2, 2, "localLocation",
+ d->localLocation);
+ opac_element_str(wrbuf, cd1, cd2, 2, "shelvingLocation",
+ d->shelvingLocation);
+ opac_element_str(wrbuf, cd1, cd2, 2, "callNumber",
+ d->callNumber);
+ opac_element_str(wrbuf, cd1, cd2, 2, "shelvingData",
+ d->shelvingData);
+ opac_element_str(wrbuf, cd1, cd2, 2, "copyNumber",
+ d->copyNumber);
+ opac_element_str(wrbuf, cd1, cd2, 2, "publicNote",
+ d->publicNote);
+ opac_element_str(wrbuf, cd1, cd2, 2, "reproductionNote",
+ d->reproductionNote);
+ opac_element_str(wrbuf, cd1, cd2, 2, "termsUseRepro",
+ d->termsUseRepro);
+ opac_element_str(wrbuf, cd1, cd2, 2, "enumAndChron",
+ d->enumAndChron);
if (d->num_volumes)
{
wrbuf_puts (wrbuf, " <volumes>\n");
for (j = 0; j<d->num_volumes; j++)
{
wrbuf_puts (wrbuf, " <volume>\n");
- opac_element_str(wrbuf, cd, 4, "enumeration",
+ opac_element_str(wrbuf, cd1, cd2, 4, "enumeration",
d->volumes[j]->enumeration);
- opac_element_str(wrbuf, cd, 4, "chronology",
+ opac_element_str(wrbuf, cd1, cd2, 4, "chronology",
d->volumes[j]->chronology);
- opac_element_str(wrbuf, cd, 4, "enumAndChron",
+ opac_element_str(wrbuf, cd1, cd2, 4, "enumAndChron",
d->volumes[j]->enumAndChron);
wrbuf_puts(wrbuf, " </volume>\n");
}
wrbuf_puts(wrbuf," <circulation>\n");
opac_element_bool(wrbuf, 4, "availableNow",
d->circulationData[j]->availableNow);
- opac_element_str(wrbuf, cd, 4, "availabiltyDate",
+ opac_element_str(wrbuf, cd1, cd2, 4, "availabiltyDate",
d->circulationData[j]->availablityDate);
- opac_element_str(wrbuf, cd, 4, "availableThru",
+ opac_element_str(wrbuf, cd1, cd2, 4, "availableThru",
d->circulationData[j]->availableThru);
- opac_element_str(wrbuf, cd, 4, "restrictions",
+ opac_element_str(wrbuf, cd1, cd2, 4, "restrictions",
d->circulationData[j]->restrictions);
- opac_element_str(wrbuf, cd, 4, "itemId",
+ opac_element_str(wrbuf, cd1, cd2, 4, "itemId",
d->circulationData[j]->itemId);
opac_element_bool(wrbuf, 4, "renewable",
d->circulationData[j]->renewable);
opac_element_bool(wrbuf, 4, "onHold",
d->circulationData[j]->onHold);
- opac_element_str(wrbuf, cd, 4, "enumAndChron",
+ opac_element_str(wrbuf, cd1, cd2, 4, "enumAndChron",
d->circulationData[j]->enumAndChron);
- opac_element_str(wrbuf, cd, 4, "midspine",
+ opac_element_str(wrbuf, cd1, cd2, 4, "midspine",
d->circulationData[j]->midspine);
- opac_element_str(wrbuf, cd, 4, "temporaryLocation",
+ opac_element_str(wrbuf, cd1, cd2, 4, "temporaryLocation",
d->circulationData[j]->temporaryLocation);
wrbuf_puts(wrbuf, " </circulation>\n");
}
void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf)
{
- yaz_opac_decode_wrbuf2(mt, r, wrbuf, yaz_marc_get_iconv(mt));
+ yaz_opac_decode_wrbuf2(mt, r, wrbuf, 0);
}
/*
char *from_set1 = 0;
char *from_set2 = 0;
char *to_set = 0;
- if (record_charset)
+ if (record_charset && *record_charset)
{
char *cp = charset_buf;
request_delq(&h->outgoing);
xfree(h);
xmalloc_trav("session closed");
- if (cb && cb->one_shot)
- {
- exit(0);
- }
}
static void do_close_req(association *a, int reason, char *message,
#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
)
{
&ex.extraRecordData_buf,
&ex.extraRecordData_len) )
;
- else if (match_xsd_string(ptr, "recordIdentifier", o,
- &ex.recordIdentifier))
- ;
-
+ else
+ match_xsd_string(ptr, "recordIdentifier", o,
+ &ex.recordIdentifier);
}
if (data_ptr)
{
if (match_xsd_string(ptr, "versionType", o,
&rec->versionType))
;
- else if (match_xsd_string(ptr, "versionValue", o,
- &rec->versionValue))
- ;
+ else
+ match_xsd_string(ptr, "versionValue", o, &rec->versionValue);
}
}
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 &&
else if (match_xsd_string(rptr, "details", o,
&(*recs)[i].details))
;
- else if (match_xsd_string(rptr, "message", o,
- &(*recs)[i].message))
- ;
+ else
+ match_xsd_string(rptr, "message", o, &(*recs)[i].message);
}
i++;
}
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))
;
- else if (match_xsd_string(ptr, "whereInList", o,
- &term->whereInList))
- ;
+ else
+ match_xsd_string(ptr, "whereInList", o, &term->whereInList);
}
}
else if (o->direction == ODR_ENCODE)
&(*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))
- ;
- else if (match_xsd_string(ptr, "database", o,
- &req->database))
+ &req->stylesheet))
;
+ else
+ match_xsd_string(ptr, "database", o, &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))
- ;
- else if (match_xsd_string(ptr, "database", o,
- &req->database))
+ &req->recordPacking))
;
+ else
+ match_xsd_string(ptr, "database", o, &req->database);
}
}
else if (!xmlStrcmp(method->name, BAD_CAST "explainResponse"))
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))
else if (match_xsd_string(ptr, "stylesheet", o,
&req->stylesheet))
;
- else if (match_xsd_string(ptr, "database", o,
- &req->database))
- ;
+ else
+ match_xsd_string(ptr, "database", o, &req->database);
}
}
else if (!xmlStrcmp(method->name, BAD_CAST "scanResponse"))
client_data, ns_ucp_str);
}
else if (match_xsd_string(ptr, "stylesheet", o,
- &req->stylesheet))
- ;
- else if (match_xsd_string(ptr, "database", o,
- &req->database))
+ &req->stylesheet))
;
+ else
+ match_xsd_string(ptr, "database", o, &req->database);
}
}
else if (!xmlStrcmp(method->name, BAD_CAST "updateResponse"))
&(*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))
}
}
+static void remove_listeners(void);
+
/*
* handle incoming connect requests.
* The dynamic mode is a bit tricky mostly because we want to avoid
return;
}
+ if (control_block.one_shot)
+ remove_listeners();
+
yaz_log(log_sessiondetail, "Connect from %s", cs_addrstr(new_line));
no_sessions++;
return 0; /* OK */
}
+static void remove_listeners(void)
+{
+ IOCHAN l = pListener;
+ for (; l; l = l->next)
+ iochan_destroy(l);
+}
+
#ifndef WIN32
/* UNIX only (for windows we don't need to catch the signals) */
static void catchchld(int num)
icu_buf_utf16_copy(dst, src);
}
else {
- const char *cstr = (const char *) sb_symbol;
- icu_utf16_from_utf8_cstr(dst, cstr , status);
+
+ const char *cstr2 = (const char *) sb_symbol;
+ icu_utf16_from_utf8_cstr(dst, cstr2 , status);
+#if 0
+ yaz_log(YLOG_DEBUG, "stemming %s to %s ", cstr, cstr2);
+#endif
}
}
icu_buf_utf8_destroy(utf8_buf);
va_end(ap);
}
-static void wrbuf_iconv_write_x(WRBUF b, yaz_iconv_t cd, const char *buf,
- size_t size, int cdata)
+int wrbuf_iconv_write_x(WRBUF b, yaz_iconv_t cd, const char *buf,
+ size_t size, int cdata)
{
+ int ret = 0;
if (cd)
{
char outbuf[128];
{
int e = yaz_iconv_error(cd);
if (e != YAZ_ICONV_E2BIG)
+ {
+ ret = -1;
break;
+ }
}
if (cdata)
wrbuf_xmlputs_n(b, outbuf, outp - outbuf);
else
wrbuf_write(b, buf, size);
}
+ return ret;
}
void wrbuf_iconv_write(WRBUF b, yaz_iconv_t cd, const char *buf, size_t size)
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;
return "CCL configuration error";
case ZOOM_ERROR_CCL_PARSE:
return "CCL parsing error";
+ case ZOOM_ERROR_ES_INVALID_ACTION:
+ return "Extended Service. invalid action";
+ case ZOOM_ERROR_ES_INVALID_VERSION:
+ return "Extended Service. invalid version";
+ case ZOOM_ERROR_ES_INVALID_SYNTAX:
+ return "Extended Service. invalid syntax";
default:
return diagbib1_str(error);
}
p->odr_out);
}
if (!syntax_oid)
+ {
+ ZOOM_set_error(p->connection, ZOOM_ERROR_ES_INVALID_SYNTAX, syntax_str);
return 0;
+ }
if (num_db > 0)
first_db = db[0];
- switch(*version)
+ switch (*version)
{
case '1':
package_oid = yaz_oid_extserv_database_update_first_version;
package_oid = yaz_oid_extserv_database_update;
break;
default:
+ ZOOM_set_error(p->connection, ZOOM_ERROR_ES_INVALID_VERSION, version);
return 0;
}
else if (!strcmp(action, "specialUpdate"))
action_no = Z_IUOriginPartToKeep_specialUpdate;
else
+ {
+ ZOOM_set_error(p->connection, ZOOM_ERROR_ES_INVALID_ACTION, action);
return 0;
+ }
apdu = create_es_package(p, package_oid);
if (apdu)
}
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)
yaz_file_globfree(&glob_res);
}
-static check_file(const char *got, const char *expect)
+static int check_file(const char *got, const char *expect)
{
const char *f = got;
size_t l_match = strlen(expect);
#if YAZ_HAVE_ICU
#include <yaz/icu_I18N.h>
+#include <unicode/uclean.h>
#if YAZ_POSIX_THREADS
#include <pthread.h>
if (!xml_node)
return ;
- chain = icu_chain_xml_config(xml_node, 0, &status);
+ chain = icu_chain_xml_config(xml_node, 1, &status);
xmlFreeDoc(doc);
YAZ_CHECK(chain);
const char *expected)
{
yaz_icu_iter_t iter = icu_iter_create(chain);
- WRBUF result, second;
+ WRBUF result, second, sort_result;
int success = 1;
if (!iter)
return 0;
}
+ sort_result = wrbuf_alloc();
result = wrbuf_alloc();
icu_iter_first(iter, input);
while (icu_iter_next(iter))
{
+ const char *sort_str = icu_iter_get_sortkey(iter);
+ if (sort_str)
+ {
+ wrbuf_puts(sort_result, "[");
+ wrbuf_puts_escaped(sort_result, sort_str);
+ wrbuf_puts(sort_result, "]");
+ }
+ else
+ {
+ wrbuf_puts(sort_result, "[NULL]");
+ }
wrbuf_puts(result, "[");
wrbuf_puts(result, icu_iter_get_norm(iter));
wrbuf_puts(result, "]");
}
-
+ yaz_log(YLOG_LOG, "sortkey=%s", wrbuf_cstr(sort_result));
second = wrbuf_alloc();
icu_iter_first(iter, input);
while (icu_iter_next(iter))
wrbuf_destroy(result);
wrbuf_destroy(second);
+ wrbuf_destroy(sort_result);
return success;
}
struct icu_chain *chain = (struct icu_chain *) p;
int i;
- for (i = 0; i < 10000; i++)
+ for (i = 0; i < 1000; i++)
{
YAZ_CHECK(test_iter(chain, "Adobe Acrobat Reader, 1991-1999.",
"[adobe][acrobat][reader][1991][][1999][]"));
pthread_join(t[i], 0);
#endif
}
+
static void check_icu_iter2(void)
{
UErrorCode status = U_ZERO_ERROR;
if (!xml_node)
return ;
- chain = icu_chain_xml_config(xml_node, 0, &status);
+ chain = icu_chain_xml_config(xml_node, 1, &status);
xmlFreeDoc(doc);
YAZ_CHECK(chain);
YAZ_CHECK(test_iter(chain, "Adobe Acrobat Reader, 1991-1999.",
"[adobe][acrobat][reader][1991][][1999][]"));
+ YAZ_CHECK(test_iter(chain, "Νόταρης, Γιάννης Σωτ",
+ "[νόταρης][γιάννης][σωτ]"));
+
check_iter_threads(chain);
icu_chain_destroy(chain);
}
+static void check_icu_iter3(void)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ struct icu_chain * chain = 0;
+ xmlNode *xml_node;
+
+ const char * xml_str =
+ "<icu_chain id=\"sort\" locale=\"el\">\n"
+ "<transform rule=\"[:Control:] Any-Remove\"/>\n"
+ "<transform rule=\"[[:Control:][:WhiteSpace:][:Punctuation:]] Remove\"/>\n"
+ "<transform rule=\"NFD; [:Nonspacing Mark:] Remove; NFC\"/>\n"
+ "<casemap rule=\"l\"/>\n"
+ "<display/>\n"
+ "</icu_chain>\n";
+
+ xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str));
+ YAZ_CHECK(doc);
+ if (!doc)
+ return;
+ xml_node = xmlDocGetRootElement(doc);
+ YAZ_CHECK(xml_node);
+ if (!xml_node)
+ return ;
+
+ chain = icu_chain_xml_config(xml_node, 1, &status);
+
+ xmlFreeDoc(doc);
+ YAZ_CHECK(chain);
+ if (!chain)
+ return;
+
+ YAZ_CHECK(test_iter(chain, "Adobe Acrobat Reader, 1991-1999.",
+ "[adobeacrobatreader19911999]"));
+
+ YAZ_CHECK(test_iter(chain, "Νόταρης, Γιάννης Σωτ",
+ "[νοταρηςγιαννηςσωτ]"));
+
+ icu_chain_destroy(chain);
+}
+
#endif /* YAZ_HAVE_ICU */
int main(int argc, char **argv)
check_icu_chain();
check_chain_empty_token();
check_chain_empty_chain();
- check_icu_iter1();
+ check_icu_iter1();
check_icu_iter2();
-
+ check_icu_iter3();
+
check_bug_1140();
+ u_cleanup();
#else /* YAZ_HAVE_ICU */
yaz_log(YLOG_LOG, "ICU unit tests omitted");
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <yaz/test.h>
* Copyright (C) 1995-2011 Index Data
* See the file LICENSE for details.
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <yaz/record_conv.h>
#include <yaz/test.h>
#include <yaz/wrbuf.h>
#include <string.h>
#include <yaz/log.h>
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#if YAZ_HAVE_XML2
#include <libxml/parser.h>
* Copyright (C) 1995-2011 Index Data
* See the file LICENSE for details.
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <yaz/retrieval.h>
#include <yaz/test.h>
#include <yaz/wrbuf.h>
#include <string.h>
#include <yaz/log.h>
-#if HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#if YAZ_HAVE_XSLT
#include <libxml/parser.h>
static void usage(const char *prog)
{
- fprintf (stderr, "Usage: %s [-i format] [-o format] [-f from] [-t to] "
- "[-l pos=value] [-c cfile] [-s prefix] [-C size] [-n] "
- "[-p] [-v] [-V] file...\n",
- prog);
+ fprintf(stderr, "Usage: %s [-i format] [-o format] [-f from] [-t to] "
+ "[-l pos=value] [-c cfile] [-s prefix] [-C size] [-n] "
+ "[-p] [-v] [-V] file...\n",
+ prog);
}
static void show_version(void)
FILE *inf = fopen(fname, "rb");
if (!inf)
{
- fprintf (stderr, "%s: cannot open %s:%s\n",
- prog, fname, strerror (errno));
+ fprintf(stderr, "%s: cannot open %s:%s\n",
+ prog, fname, strerror(errno));
exit(1);
}
int split_file_no = -1;
if (!inf)
{
- fprintf (stderr, "%s: cannot open %s:%s\n",
- prog, fname, strerror (errno));
+ fprintf(stderr, "%s: cannot open %s:%s\n",
+ prog, fname, strerror(errno));
exit(1);
}
if (cfile)
- fprintf (cfile, "char *marc_records[] = {\n");
+ fprintf(cfile, "char *marc_records[] = {\n");
for(;; marc_no++)
{
const char *result = 0;
size_t r;
char buf[100001];
- r = fread (buf, 1, 5, inf);
+ r = fread(buf, 1, 5, inf);
if (r < 5)
{
if (r && print_offset && verbose)
- printf ("<!-- Extra %ld bytes at end of file -->\n",
- (long) r);
+ printf("<!-- Extra %ld bytes at end of file -->\n",
+ (long) r);
break;
}
while (*buf < '0' || *buf > '9')
if (r < 1)
{
if (verbose || print_offset)
- printf ("<!-- End of file with data -->\n");
+ printf("<!-- End of file with data -->\n");
break;
}
if (print_offset)
{
long off = ftell(inf) - 5;
- printf ("<!-- Record %d offset %ld (0x%lx) -->\n",
- num, off, off);
+ printf("<!-- Record %d offset %ld (0x%lx) -->\n",
+ num, off, off);
}
len = atoi_n(buf, 5);
if (len < 25 || len > 100000)
break;
}
rlen = len - 5;
- r = fread (buf + 5, 1, rlen, inf);
+ r = fread(buf + 5, 1, rlen, inf);
if (r < rlen)
break;
while (buf[len-1] != ISO2709_RS)
{
if (len > sizeof(buf)-2)
break;
- r = fread (buf + len, 1, 1, inf);
+ r = fread(buf + len, 1, 1, inf);
if (r != 1)
break;
len++;
char *p = buf;
size_t i;
if (marc_no)
- fprintf (cfile, ",");
- fprintf (cfile, "\n");
+ fprintf(cfile, ",");
+ fprintf(cfile, "\n");
for (i = 0; i < r; i++)
{
if ((i & 15) == 0)
- fprintf (cfile, " \"");
- fprintf (cfile, "\\x%02X", p[i] & 255);
+ fprintf(cfile, " \"");
+ fprintf(cfile, "\\x%02X", p[i] & 255);
if (i < r - 1 && (i & 15) == 15)
- fprintf (cfile, "\"\n");
+ fprintf(cfile, "\"\n");
}
- fprintf (cfile, "\"\n");
+ fprintf(cfile, "\"\n");
}
num++;
if (verbose)
printf("\n");
}
if (cfile)
- fprintf (cfile, "};\n");
+ fprintf(cfile, "};\n");
fclose(inf);
}
{
break;
case 'c':
if (cfile)
- fclose (cfile);
+ fclose(cfile);
cfile = fopen(arg, "w");
break;
case 'x':
}
}
if (cfile)
- fclose (cfile);
+ fclose(cfile);
if (!no)
{
usage(prog);
- exit (1);
+ exit(1);
}
- exit (0);
+ exit(0);
}
/*
* Local variables:
#include <stdio.h>
#include <stdlib.h>
+#include <errno.h>
#include <yaz/options.h>
#include <unicode/ucol.h>
#include <unicode/ubrk.h>
#include <unicode/utrans.h>
+#include <unicode/uclean.h>
#include <yaz/icu.h>
#include <yaz/wrbuf.h>
/* commando line and config parameters */
-static struct config_t {
+struct config_t {
char conffile[1024];
char print[1024];
int xmloutput;
yaz_icu_chain_t chain;
FILE * infile;
FILE * outfile;
-} config;
-
-
+};
void print_option_error(const struct config_t *p_config)
{
- fprintf(stderr, "Calling error, valid options are :\n");
- fprintf(stderr, "yaz-icu\n"
- " [-c (path/to/config/file.xml)]\n"
- " [-p (a|c|l|t)] print ICU info \n"
- " [-s] Show sort normalization key\n"
- " [-x] XML output\n"
+ fprintf(stderr, "yaz-icu [options] [infile]\n"
+ "Options:\n"
+ " -c file XML configuration\n"
+ " -p a|c|l|t Print ICU info \n"
+ " -s Show sort normalization key\n"
+ " -x XML output instread of text\n"
"\n"
"Examples:\n"
"cat hugetextfile.txt | ./yaz-icu -c config.xml \n"
p_config->xmloutput = 0;
p_config->sortoutput = 0;
p_config->chain = 0;
- p_config->infile = stdin;
+ p_config->infile = 0;
p_config->outfile = stdout;
/* set up command line parameters */
case 'x':
p_config->xmloutput = 1;
break;
+ case 0:
+ if (p_config->infile)
+ {
+ fprintf(stderr, "yaz-icu: only one input file may be given\n");
+ print_option_error(p_config);
+ }
+ p_config->infile = fopen(arg, "r");
+ if (!p_config->infile)
+ {
+ fprintf(stderr, "yaz-icu: cannot open %s : %s\n",
+ arg, strerror(errno));
+ exit(1);
+ }
+ break;
default:
- printf("Got %d\n", ret);
+ fprintf(stderr, "yaz_icu: invalid option: %s\n", arg);
print_option_error(p_config);
}
}
-
- if ((!strlen(p_config->conffile)
- && !strlen(p_config->print))
- || !config.infile
- || !config.outfile)
-
- print_option_error(p_config);
-}
-
-
-/* UConverter *conv; */
-/* conv = ucnv_open("utf-8", &status); */
-/* assert(U_SUCCESS(status)); */
-
-/* *ustr16_len */
-/* = ucnv_toUChars(conv, ustr16, 1024, */
-/* (const char *) *xstr8, strlen((const char *) *xstr8), */
-/* &status); */
-
+ if (p_config->infile == 0)
+ p_config->infile = stdin;
-/* ucnv_fromUChars(conv, */
-/* (char *) *xstr8, strlen((const char *) *xstr8), */
-/* ustr16, *ustr16_len, */
-/* &status); */
-/* ucnv_close(conv); */
-
+ if (!strlen(p_config->conffile) && !strlen(p_config->print))
+ print_option_error(p_config);
+}
static void print_icu_converters(const struct config_t *p_config)
{
count = ucnv_countAvailable();
if (p_config->xmloutput)
- fprintf(config.outfile, "<converters count=\"%d\" default=\"%s\">\n",
+ fprintf(p_config->outfile, "<converters count=\"%d\" default=\"%s\">\n",
count, ucnv_getDefaultName());
else
{
- fprintf(config.outfile, "Available ICU converters: %d\n", count);
- fprintf(config.outfile, "Default ICU Converter is: '%s'\n",
+ fprintf(p_config->outfile, "Available ICU converters: %d\n", count);
+ fprintf(p_config->outfile, "Default ICU Converter is: '%s'\n",
ucnv_getDefaultName());
}
for (i = 0; i < count; i++)
{
if (p_config->xmloutput)
- fprintf(config.outfile, "<converter id=\"%s\"/>\n",
+ fprintf(p_config->outfile, "<converter id=\"%s\"/>\n",
ucnv_getAvailableName(i));
else
- fprintf(config.outfile, "%s\n", ucnv_getAvailableName(i));
+ fprintf(p_config->outfile, "%s\n", ucnv_getAvailableName(i));
}
if (p_config->xmloutput)
- fprintf(config.outfile, "</converters>\n");
+ fprintf(p_config->outfile, "</converters>\n");
else
- fprintf(config.outfile, "\n");
+ fprintf(p_config->outfile, "\n");
}
static void print_icu_transliterators(const struct config_t *p_config)
int32_t length;
if (p_config->xmloutput)
- fprintf(config.outfile, "<transliterators count=\"%d\">\n", count);
+ fprintf(p_config->outfile, "<transliterators count=\"%d\">\n", count);
else
- fprintf(config.outfile, "Available ICU transliterators: %d\n", count);
+ fprintf(p_config->outfile, "Available ICU transliterators: %d\n", count);
while ((name = uenum_next(en, &length, &status)))
{
if (p_config->xmloutput)
- fprintf(config.outfile, "<transliterator id=\"%s\"/>\n", name);
+ fprintf(p_config->outfile, "<transliterator id=\"%s\"/>\n", name);
else
- fprintf(config.outfile, "%s\n", name);
+ fprintf(p_config->outfile, "%s\n", name);
}
uenum_close(en);
if (p_config->xmloutput)
- fprintf(config.outfile, "</transliterators>\n");
+ fprintf(p_config->outfile, "</transliterators>\n");
else
{
- fprintf(config.outfile, "\n\nUnicode Set Patterns:\n"
+ fprintf(p_config->outfile, "\n\nUnicode Set Patterns:\n"
" Pattern Description\n"
" Ranges [a-z] The lower case letters a through z\n"
" Named Chars [abc123] The six characters a,b,c,1,2 and 3\n"
);
- fprintf(config.outfile, "\n\n");
+ fprintf(p_config->outfile, "\n\n");
}
}
if (p_config->xmloutput)
{
- fprintf(config.outfile, "<locales count=\"%d\" default=\"%s\" collations=\"%d\">\n",
+ fprintf(p_config->outfile, "<locales count=\"%d\" default=\"%s\" collations=\"%d\">\n",
count, uloc_getDefault(), ucol_countAvailable());
}
else
{
- fprintf(config.outfile, "Available ICU locales: %d\n", count);
- fprintf(config.outfile, "Default locale is: %s\n", uloc_getDefault());
+ fprintf(p_config->outfile, "Available ICU locales: %d\n", count);
+ fprintf(p_config->outfile, "Default locale is: %s\n", uloc_getDefault());
}
for (i = 0; i < count; i++)
if (p_config->xmloutput)
{
- fprintf(config.outfile, "<locale id=\"%s\"", uloc_getAvailable(i));
- /* fprintf(config.outfile, " locale=\"%s\"", uloc_getAvailable(i)); */
- /* if (strlen(keyword_str)) */
- /* fprintf(config.outfile, " keyword=\"%s\"", keyword_str); */
- /* if (ucol_getAvailable(i)) */
- /* fprintf(config.outfile, " collation=\"1\""); */
+ fprintf(p_config->outfile, "<locale id=\"%s\"", uloc_getAvailable(i));
if (strlen(lang_str))
- fprintf(config.outfile, " language=\"%s\"", lang_str);
+ fprintf(p_config->outfile, " language=\"%s\"", lang_str);
if (strlen(script_str))
- fprintf(config.outfile, " script=\"%s\"", script_str);
+ fprintf(p_config->outfile, " script=\"%s\"", script_str);
if (strlen(location_str))
- fprintf(config.outfile, " location=\"%s\"", location_str);
+ fprintf(p_config->outfile, " location=\"%s\"", location_str);
if (strlen(variant_str))
- fprintf(config.outfile, " variant=\"%s\"", variant_str);
+ fprintf(p_config->outfile, " variant=\"%s\"", variant_str);
if (strlen(name_str))
- fprintf(config.outfile, " name=\"%s\"", name_str);
+ fprintf(p_config->outfile, " name=\"%s\"", name_str);
if (strlen(localname_str))
- fprintf(config.outfile, " localname=\"%s\"", localname_str);
- fprintf(config.outfile, ">");
+ fprintf(p_config->outfile, " localname=\"%s\"", localname_str);
+ fprintf(p_config->outfile, ">");
if (strlen(localname_str))
- fprintf(config.outfile, "%s", localname_str);
- fprintf(config.outfile, "</locale>\n");
+ fprintf(p_config->outfile, "%s", localname_str);
+ fprintf(p_config->outfile, "</locale>\n");
}
else if (1 == p_config->xmloutput)
{
- fprintf(config.outfile, "%s", uloc_getAvailable(i));
- fprintf(config.outfile, " | ");
+ fprintf(p_config->outfile, "%s", uloc_getAvailable(i));
+ fprintf(p_config->outfile, " | ");
if (strlen(name_str))
- fprintf(config.outfile, "%s", name_str);
- fprintf(config.outfile, " | ");
+ fprintf(p_config->outfile, "%s", name_str);
+ fprintf(p_config->outfile, " | ");
if (strlen(localname_str))
- fprintf(config.outfile, "%s", localname_str);
- fprintf(config.outfile, "\n");
+ fprintf(p_config->outfile, "%s", localname_str);
+ fprintf(p_config->outfile, "\n");
}
else
- fprintf(config.outfile, "%s\n", uloc_getAvailable(i));
+ fprintf(p_config->outfile, "%s\n", uloc_getAvailable(i));
}
if (p_config->xmloutput)
- fprintf(config.outfile, "</locales>\n");
+ fprintf(p_config->outfile, "</locales>\n");
else
- fprintf(config.outfile, "\n");
+ fprintf(p_config->outfile, "\n");
if (U_FAILURE(status))
{
static void print_info(const struct config_t *p_config)
{
if (p_config->xmloutput)
- fprintf(config.outfile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ fprintf(p_config->outfile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<icu>\n");
- if ('c' == config.print[0])
- print_icu_converters(&config);
- else if ('l' == config.print[0])
- print_icu_xml_locales(&config);
- else if ('t' == config.print[0])
- print_icu_transliterators(&config);
+ if ('c' == p_config->print[0])
+ print_icu_converters(p_config);
+ else if ('l' == p_config->print[0])
+ print_icu_xml_locales(p_config);
+ else if ('t' == p_config->print[0])
+ print_icu_transliterators(p_config);
else {
- print_icu_converters(&config);
- print_icu_xml_locales(&config);
- print_icu_transliterators(&config);
+ print_icu_converters(p_config);
+ print_icu_xml_locales(p_config);
+ print_icu_transliterators(p_config);
}
if (p_config->xmloutput)
- fprintf(config.outfile, "</icu>\n");
+ fprintf(p_config->outfile, "</icu>\n");
exit(0);
}
-static void process_text_file(const struct config_t *p_config)
+static void process_text_file(struct config_t *p_config)
{
char *line = 0;
char linebuf[1024];
- xmlDoc *doc = xmlParseFile(config.conffile);
+ xmlDoc *doc = xmlParseFile(p_config->conffile);
xmlNode *xml_node = xmlDocGetRootElement(doc);
long unsigned int token_count = 0;
if (!xml_node)
{
printf("Could not parse XML config file '%s' \n",
- config.conffile);
+ p_config->conffile);
exit(1);
}
- config.chain = icu_chain_xml_config(xml_node, 1, &status);
+ p_config->chain = icu_chain_xml_config(xml_node, 1, &status);
- if (!config.chain || !U_SUCCESS(status))
+ if (!p_config->chain || !U_SUCCESS(status))
{
printf("Could not set up ICU chain from config file '%s' \n",
- config.conffile);
+ p_config->conffile);
if (!U_SUCCESS(status))
printf("ICU Error: %d %s\n", status, u_errorName(status));
exit(1);
}
if (p_config->xmloutput)
- fprintf(config.outfile,
+ fprintf(p_config->outfile,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<icu>\n"
"<tokens>\n");
/* read input lines for processing */
- while ((line=fgets(linebuf, sizeof(linebuf)-1, config.infile)))
+ while ((line=fgets(linebuf, sizeof(linebuf)-1, p_config->infile)))
{
WRBUF sw = wrbuf_alloc();
WRBUF cdata = wrbuf_alloc();
- int success = icu_chain_assign_cstr(config.chain, line, &status);
+ int success = icu_chain_assign_cstr(p_config->chain, line, &status);
line_count++;
- while (success && icu_chain_next_token(config.chain, &status))
+ while (success && icu_chain_next_token(p_config->chain, &status))
{
if (U_FAILURE(status))
success = 0;
else
{
- const char *sortkey = icu_chain_token_sortkey(config.chain);
+ const char *sortkey = icu_chain_token_sortkey(p_config->chain);
wrbuf_rewind(sw);
wrbuf_puts_escaped(sw, sortkey);
token_count++;
if (p_config->xmloutput)
{
- fprintf(config.outfile,
+ fprintf(p_config->outfile,
"<token id=\"%lu\" line=\"%lu\"",
token_count, line_count);
wrbuf_rewind(cdata);
- wrbuf_xmlputs(cdata, icu_chain_token_norm(config.chain));
- fprintf(config.outfile, " norm=\"%s\"",
+ wrbuf_xmlputs(cdata, icu_chain_token_norm(p_config->chain));
+ fprintf(p_config->outfile, " norm=\"%s\"",
wrbuf_cstr(cdata));
wrbuf_rewind(cdata);
- wrbuf_xmlputs(cdata, icu_chain_token_display(config.chain));
- fprintf(config.outfile, " display=\"%s\"",
+ wrbuf_xmlputs(cdata, icu_chain_token_display(p_config->chain));
+ fprintf(p_config->outfile, " display=\"%s\"",
wrbuf_cstr(cdata));
if (p_config->sortoutput)
{
wrbuf_rewind(cdata);
wrbuf_xmlputs(cdata, wrbuf_cstr(sw));
- fprintf(config.outfile, " sortkey=\"%s\"",
+ fprintf(p_config->outfile, " sortkey=\"%s\"",
wrbuf_cstr(cdata));
}
- fprintf(config.outfile, "/>\n");
+ fprintf(p_config->outfile, "/>\n");
}
else
{
- fprintf(config.outfile, "%lu %lu '%s' '%s'",
+ fprintf(p_config->outfile, "%lu %lu '%s' '%s'",
token_count,
line_count,
- icu_chain_token_norm(config.chain),
- icu_chain_token_display(config.chain));
+ icu_chain_token_norm(p_config->chain),
+ icu_chain_token_display(p_config->chain));
if (p_config->sortoutput)
{
- fprintf(config.outfile, " '%s'", wrbuf_cstr(sw));
+ fprintf(p_config->outfile, " '%s'", wrbuf_cstr(sw));
}
- fprintf(config.outfile, "\n");
+ fprintf(p_config->outfile, "\n");
}
}
}
}
if (p_config->xmloutput)
- fprintf(config.outfile,
+ fprintf(p_config->outfile,
"</tokens>\n"
"</icu>\n");
- icu_chain_destroy(config.chain);
+ icu_chain_destroy(p_config->chain);
xmlFreeDoc(doc);
if (line)
free(line);
int main(int argc, char **argv)
{
+ struct config_t config;
#if YAZ_HAVE_ICU
-
read_params(argc, argv, &config);
if (config.conffile && strlen(config.conffile))
if (config.print && strlen(config.print))
print_info(&config);
+ u_cleanup();
#else /* YAZ_HAVE_ICU */
printf("ICU not available on your system.\n"
# icu charcter conversion utility
# get icu libraries from http://www.icu-project.org
HAVE_ICU=1
-ICU_DIR = c:\icu
+ICU_LIB = c:\icu\lib
+ICU_BIN = c:\icu\bin
+ICU_INCLUDE = c:\icu\include
# libxslt
HAVE_LIBXSLT=1
$(NSIS) yaz.win32.nsi
dist64: yaz.win64.nsi yaz.nsi distclean
- nmake DEBUG=0 HAVE_LIBXSLT=0 HAVE_LIBXML2=0 HAVE_ICONV=0 HAVE_ICU=0
- $(NSIS) yaz.win64.nsi
+ nmake DEBUG=0 HAVE_LIBXSLT=1 HAVE_LIBXML2=1 HAVE_ICONV=0 HAVE_ICU=1 LIBXML2_DIR=c:\libxml2-2.7.8.win64 LIBXSLT_DIR=c:\libxslt-1.1.26.win64 ICU_LIB=\icu64\lib64 ICU_INCLUDE=\icu64\include ICU_BIN=\icu64\bin64
+ $(NSIS) yaz.win64.nsi
distclean:
nmake DEBUG=1 clean
!if $(HAVE_ICU)
ICU_DEF= \
- /D YAZ_HAVE_ICU=1 /D HAVE_ICU_H=1 \
- /I"$(ICU_DIR)\include"
-ICU_LIB= \
- $(ICU_DIR)\lib\icudt.lib $(ICU_DIR)\lib\icuin.lib $(ICU_DIR)\lib\icuuc.lib
+ /D YAZ_HAVE_ICU=1 /D HAVE_ICU_H=1 /I"$(ICU_INCLUDE)"
+ICU_LIBS= \
+ $(ICU_LIB)\icudt.lib $(ICU_LIB)\icuin.lib $(ICU_LIB)\icuuc.lib
icu: $(BINDIR)\icudt42.dll $(BINDIR)\icuin42.dll $(BINDIR)\icuuc42.dll
yazicu: dirs generate $(YAZ_ICU)
$(BINDIR)\icudt42.dll:
- copy "$(ICU_DIR)\bin\icudt42.dll" $(BINDIR)
+ copy "$(ICU_BIN)\icudt42.dll" $(BINDIR)
$(BINDIR)\icuin42.dll:
- copy "$(ICU_DIR)\bin\icuin42.dll" $(BINDIR)
+ copy "$(ICU_BIN)\icuin42.dll" $(BINDIR)
$(BINDIR)\icuuc42.dll:
- copy "$(ICU_DIR)\bin\icuuc42.dll" $(BINDIR)
+ copy "$(ICU_BIN)\icuuc42.dll" $(BINDIR)
!else
ICU_DEF= \
/D YAZ_HAVE_ICU=0
-ICU_LIB=
+ICU_LIBS=
icu:
yazicu:
!endif
/Fd"$(OBJDIR)\\"
COMMON_C_INCLUDES= \
- /I"$(ROOTDIR)\include"
+ /I"$(ROOTDIR)\include" \
+ /I"$(ROOTDIR)\libstemmer_c\include"
DEBUG_C_OPTIONS= \
/D "_DEBUG" \
$(OBJDIR)\ill-core.obj\
$(OBJDIR)\item-req.obj
+STEMMER_OBJS = \
+ $(OBJDIR)\libstemmer.obj \
+ $(OBJDIR)\api.obj \
+ $(OBJDIR)\utilities.obj \
+ $(OBJDIR)\stem_UTF_8_porter.obj \
+ $(OBJDIR)\stem_UTF_8_english.obj
+
DLL_OBJS =\
$(MISC_OBJS) \
$(Z3950_OBJS) \
- $(ILL_OBJS) \
+ $(ILL_OBJS)
ICU_DLL_OBJS =\
$(OBJDIR)\icu_chain.obj \
$(OBJDIR)\icu_transform.obj \
$(OBJDIR)\icu_casemap.obj \
$(OBJDIR)\icu_tokenizer.obj \
- $(OBJDIR)\icu_sortkey.obj
+ $(OBJDIR)\icu_sortkey.obj \
+ $(OBJDIR)\stemmer.obj \
+ $(STEMMER_OBJS)
# Generated C and H files
{$(TESTDIR)}.c{$(OBJDIR)}.obj:
$(CPP) $(COPT) $<
+{$(ROOTDIR)\libstemmer_c\libstemmer}.c{$(OBJDIR)}.obj:
+ $(CPP) $(COPT) $<
+
+{$(ROOTDIR)\libstemmer_c\runtime}.c{$(OBJDIR)}.obj:
+ $(CPP) $(COPT) $<
+
+{$(ROOTDIR)\libstemmer_c\src_c}.c{$(OBJDIR)}.obj:
+ $(CPP) $(COPT) $<
+
# ASN-generated files
!if $(HAVE_TCL)
$(MT) -manifest $@.manifest -outputresource:$@;2
$(YAZ_ICU_DLL) $(YAZ_ICU_IMPLIB): "$(BINDIR)" $(ICU_DLL_OBJS) $(YAZ_ICU_RES)
- $(LINK_DLL) $(ICU_LIB) $(YAZ_IMPLIB)\
+ $(LINK_DLL) $(ICU_LIBS) $(YAZ_IMPLIB)\
$(ICU_DLL_OBJS) \
$(YAZ_ICU_RES) \
/out:$@ \
$(MT) -manifest $@.manifest -outputresource:$@;1
$(YAZ_ICU) : "$(BINDIR)" $(YAZ_ICU_OBJS) $(YAZ_ICU_DLL)
- $(LINK_PROGRAM) $(ICU_LIB) $(YAZ_ICU_IMPLIB) $(YAZ_ICU_OBJS) /out:$@
+ $(LINK_PROGRAM) $(ICU_LIBS) $(YAZ_ICU_IMPLIB) $(YAZ_ICU_OBJS) /out:$@
$(MT) -manifest $@.manifest -outputresource:$@;1
Section "YAZ Source" YAZ_Source
SectionIn 1
SetOutPath $INSTDIR
+ File ..\configure.ac
File /r ..\*.c
File /r /x yaz ..\*.h
SetOutPath $INSTDIR\util
Name: yaz
Summary: Z39.50 Programs
-Version: 4.1.4
+Version: 4.1.7
Release: 1indexdata
# determine system