* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $Id: wrbuf.h,v 1.27 2007-09-17 19:14:26 adam Exp $ */
+/* $Id: wrbuf.h,v 1.28 2007-11-15 08:45:52 adam Exp $ */
/**
* \file wrbuf.h
/** \brief empty WRBUF content */
YAZ_EXPORT void wrbuf_rewind(WRBUF b);
-/** \brief grow WRBUF larger */
-YAZ_EXPORT int wrbuf_grow(WRBUF b, int minsize);
+/** \brief writes (append) buffer to WRBUF */
YAZ_EXPORT int wrbuf_write(WRBUF b, const char *buf, int size);
-YAZ_EXPORT int wrbuf_xmlputs_n(WRBUF b, const char *cp, int size);
+/** \brief appends C-string to WRBUF */
YAZ_EXPORT int wrbuf_puts(WRBUF b, const char *buf);
+
+/** \brief writes buffer to WRBUF and XML encode (as CDATA) */
+YAZ_EXPORT int wrbuf_xmlputs_n(WRBUF b, const char *cp, int size);
+/** \brief writes C-String to WRBUF and XML encode (as CDATA) */
+YAZ_EXPORT int wrbuf_xmlputs(WRBUF b, const char *cp);
+
YAZ_EXPORT int wrbuf_puts_replace_char(WRBUF b, const char *buf,
const char from, const char to);
-YAZ_EXPORT int wrbuf_xmlputs(WRBUF b, const char *cp);
+
+/** \brief writes buffer to WRBUF and escape non-ASCII characters */
+YAZ_EXPORT void wrbuf_puts_escaped(WRBUF b, const char *str);
+
+/** \brief writes C-string to WRBUF and escape non-ASCII characters */
+YAZ_EXPORT void wrbuf_write_escaped(WRBUF b, const char *buf, size_t len);
+
+/** \brief writes printf result to WRBUF */
YAZ_EXPORT void wrbuf_printf(WRBUF b, const char *fmt, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)))
/** \brief cut size of WRBUF */
YAZ_EXPORT void wrbuf_cut_right(WRBUF b, size_t no_to_remove);
+
+/** \brief grow WRBUF larger
+ This function is normally not used by applications
+*/
+YAZ_EXPORT int wrbuf_grow(WRBUF b, int minsize);
+
#define wrbuf_len(b) ((b)->pos)
#define wrbuf_buf(b) ((b)->buf)
(((b)->pos >= (b)->size ? wrbuf_grow(b, 1) : 0), \
(b)->buf[(b)->pos++] = (c), 0)
-/** \brief put readable string in WRBUF from raw input */
-YAZ_EXPORT void wrbuf_verbose_str(WRBUF b, const char *str, size_t len);
-
YAZ_END_CDECL
#endif
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: wrbuf.c,v 1.21 2007-10-15 12:00:31 adam Exp $
+ * $Id: wrbuf.c,v 1.22 2007-11-15 08:45:52 adam Exp $
*/
/**
b->pos = b->pos - no_to_remove;
}
-void wrbuf_verbose_str(WRBUF b, const char *str, size_t len)
+void wrbuf_puts_escaped(WRBUF b, const char *str)
+{
+ return wrbuf_write_escaped(b, str, strlen(str));
+}
+
+void wrbuf_write_escaped(WRBUF b, const char *str, size_t len)
{
size_t i;
for (i = 0; i < len; i++)
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: yaz-icu.c,v 1.14 2007-11-15 08:28:08 adam Exp $
+ * $Id: yaz-icu.c,v 1.15 2007-11-15 08:45:52 adam Exp $
*/
#if HAVE_CONFIG_H
else {
const char *sortkey = icu_chain_token_sortkey(config.chain);
wrbuf_rewind(sw);
- wrbuf_verbose_str(sw, sortkey, strlen(sortkey));
+ wrbuf_puts_escaped(sw, sortkey);
token_count++;
if (p_config->xmloutput)
+ {
+ /* should XML encode this. Bug #1902 */
fprintf(config.outfile,
"<token id=\%lu\" line=\"%lu\""
" norm=\"%s\" display=\"%s\" sortkey=\"%s\"/>\n",
icu_chain_token_norm(config.chain),
icu_chain_token_display(config.chain),
wrbuf_cstr(sw));
+ }
else
fprintf(config.outfile, "%lu %lu '%s' '%s' '%s'\n",
token_count,