+ cql_pr_attr(ct, "position", "any", 0,
+ pr, client_data, YAZ_SRW_ANCHORING_CHAR_IN_UNSUPP_POSITION);
+ }
+ }
+
+ if (process_term && length > 0)
+ {
+ const char *first_wc = wcchar(1, term, length);
+ const char *second_wc = first_wc ?
+ wcchar(0, first_wc+1, length-(first_wc-term)-1) : 0;
+
+ /* Check for well-known globbing patterns that represent
+ * simple truncation attributes as expected by, for example,
+ * Bath-compliant server. If we find such a pattern but
+ * there's no mapping for it, that's fine: we just use a
+ * general pattern-matching attribute.
+ */
+ if (first_wc == term && second_wc == term + length-1
+ && *first_wc == '*' && *second_wc == '*'
+ && cql_pr_attr(ct, "truncation", "both", 0, pr, client_data, 0))
+ {
+ term++;
+ length -= 2;
+ }
+ else if (first_wc == term && second_wc == 0 && *first_wc == '*'
+ && cql_pr_attr(ct, "truncation", "left", 0,
+ pr, client_data, 0))
+ {
+ term++;
+ length--;
+ }
+ else if (first_wc == term + length-1 && second_wc == 0
+ && *first_wc == '*'
+ && cql_pr_attr(ct, "truncation", "right", 0,
+ pr, client_data, 0))
+ {
+ length--;
+ }
+ else if (first_wc)
+ {
+ /* We have one or more wildcard characters, but not in a
+ * way that can be dealt with using only the standard
+ * left-, right- and both-truncation attributes. We need
+ * to translate the pattern into a Z39.58-type pattern,
+ * which has been supported in BIB-1 since 1996. If
+ * there's no configuration element for "truncation.z3958"
+ * we indicate this as error 28 "Masking character not
+ * supported".
+ */
+ int i;
+ cql_pr_attr(ct, "truncation", "z3958", 0,
+ pr, client_data, YAZ_SRW_MASKING_CHAR_UNSUPP);
+ z3958_mem = (char *) xmalloc(length+1);
+ for (i = 0; i < length; i++)
+ {
+ if (i > 0 && term[i-1] == '\\')
+ z3958_mem[i] = term[i];
+ else if (term[i] == '*')
+ z3958_mem[i] = '?';
+ else if (term[i] == '?')
+ z3958_mem[i] = '#';
+ else
+ z3958_mem[i] = term[i];
+ }
+ z3958_mem[length] = '\0';
+ term = z3958_mem;
+ }
+ else {
+ /* No masking characters. Use "truncation.none" if given. */
+ cql_pr_attr(ct, "truncation", "none", 0,
+ pr, client_data, 0);
+ }
+ }
+ if (ns) {
+ cql_pr_attr_uri(ct, "index", ns,
+ cn->u.st.index, "serverChoice",
+ pr, client_data, YAZ_SRW_UNSUPP_INDEX);
+ }
+ if (cn->u.st.modifiers)
+ {
+ struct cql_node *mod = cn->u.st.modifiers;
+ for (; mod; mod = mod->u.st.modifiers)
+ {
+ cql_pr_attr(ct, "relationModifier", mod->u.st.index, 0,
+ pr, client_data, YAZ_SRW_UNSUPP_RELATION_MODIFIER);