- if (s->which == Z_RPNStructure_simple)
- {
- Z_Operand *o = s->u.simple;
-
- if (o->which == Z_Operand_APT)
- {
- Z_AttributesPlusTerm *at = s->u.simple->u.attributesPlusTerm;
- if (at->attributes) {
- int i;
- for (i = 0; i < at->attributes->num_attributes; i++) {
- wrbuf_puts(buf, "@attr ");
- if (at->attributes->attributes[i]->attributeSet) {
- oid2str(at->attributes->attributes[i]->attributeSet, buf);
- wrbuf_putc(buf, ' ');
- }
- wrbuf_printf(buf, "%d=", *at->attributes->attributes[i]->attributeType);
- wrbuf_printf(buf, "%d ", *at->attributes->attributes[i]->value.numeric);
- }
- }
- if (at->term->which == Z_Term_general)
- {
- pr_term(buf, (char*) at->term->u.general->buf,
- at->term->u.general->len);
- }
- else if (at->term->which == Z_Term_characterString)
- {
- wrbuf_puts(buf, "@term string ");
- pr_term(buf, at->term->u.characterString,
- strlen(at->term->u.characterString));
-
- }
- }
- else if (o->which == Z_Operand_resultSetId)
- {
- wrbuf_printf(buf, "@set %s ", o->u.resultSetId);
- }
- }
- else if (s->which == Z_RPNStructure_complex)
+ Z_Query *query;
+ *str = 0;
+ if (!m_p->buf)
+ return;
+ odr_setbuf(m_p->odr_decode, m_p->buf, m_p->len, 0);
+ if (!z_Query(m_p->odr_decode, &query, 0, 0))
+ return;
+ WRBUF wbuf = wrbuf_alloc();
+ yaz_query_to_wrbuf(wbuf, query);
+ if (wrbuf_len(wbuf) > len-1)