YAZ_EXPORT void wrbuf_rewind(WRBUF b);
/** \brief writes (append) buffer to WRBUF */
-YAZ_EXPORT int wrbuf_write(WRBUF b, const char *buf, int size);
+YAZ_EXPORT void wrbuf_write(WRBUF b, const char *buf, size_t size);
/** \brief appends C-string to WRBUF (returns int) */
-YAZ_EXPORT int wrbuf_puts(WRBUF b, const char *buf);
+YAZ_EXPORT void wrbuf_puts(WRBUF b, const char *buf);
/** \brief appends C-string to WRBUF (void) */
YAZ_EXPORT void wrbuf_vputs(const char *buf, void *client_data);
/** \brief writes buffer to WRBUF and XML encode (as CDATA) */
-YAZ_EXPORT int wrbuf_xmlputs_n(WRBUF b, const char *cp, int size);
+YAZ_EXPORT void wrbuf_xmlputs_n(WRBUF b, const char *cp, size_t size);
/** \brief writes C-String to WRBUF and XML encode (as CDATA) */
-YAZ_EXPORT int wrbuf_xmlputs(WRBUF b, const char *cp);
+YAZ_EXPORT void 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 void wrbuf_puts_replace_char(WRBUF b, const char *buf,
+ const char from, const char to);
/** \brief writes buffer to WRBUF and escape non-ASCII characters */
YAZ_EXPORT void wrbuf_puts_escaped(WRBUF b, const char *str);
#endif
;
-YAZ_EXPORT int wrbuf_iconv_write(WRBUF b, yaz_iconv_t cd, const char *buf,
- int size);
-YAZ_EXPORT int wrbuf_iconv_write_cdata(WRBUF b, yaz_iconv_t cd,
- const char *buf, int size);
-YAZ_EXPORT int wrbuf_iconv_puts_cdata(WRBUF b, yaz_iconv_t cd,
- const char *strz);
+YAZ_EXPORT void wrbuf_iconv_write(WRBUF b, yaz_iconv_t cd, const char *buf,
+ size_t size);
+YAZ_EXPORT void wrbuf_iconv_write_cdata(WRBUF b, yaz_iconv_t cd,
+ const char *buf, size_t size);
+YAZ_EXPORT void wrbuf_iconv_puts_cdata(WRBUF b, yaz_iconv_t cd,
+ const char *strz);
-YAZ_EXPORT int wrbuf_iconv_puts(WRBUF b, yaz_iconv_t cd, const char *strz);
+YAZ_EXPORT void wrbuf_iconv_puts(WRBUF b, yaz_iconv_t cd, const char *strz);
-YAZ_EXPORT int wrbuf_iconv_putchar(WRBUF b, yaz_iconv_t cd, int ch);
+YAZ_EXPORT void wrbuf_iconv_putchar(WRBUF b, yaz_iconv_t cd, int ch);
YAZ_EXPORT void wrbuf_iconv_reset(WRBUF b, yaz_iconv_t cd);
/** \brief grow WRBUF larger
This function is normally not used by applications
*/
-YAZ_EXPORT int wrbuf_grow(WRBUF b, int minsize);
+YAZ_EXPORT int wrbuf_grow(WRBUF b, size_t minsize);
#define wrbuf_len(b) ((b)->pos)
#define wrbuf_buf(b) ((b)->buf)
b->pos = 0;
}
-int wrbuf_grow(WRBUF b, int minsize)
+int wrbuf_grow(WRBUF b, size_t minsize)
{
- int togrow;
+ size_t togrow;
if (!b->size)
togrow = 1024;
return 0;
}
-int wrbuf_write(WRBUF b, const char *buf, int size)
+void wrbuf_write(WRBUF b, const char *buf, size_t size)
{
if (size <= 0)
- return 0;
+ return;
if (b->pos + size >= b->size)
wrbuf_grow(b, size);
memcpy(b->buf + b->pos, buf, size);
b->pos += size;
- return 0;
}
-int wrbuf_puts(WRBUF b, const char *buf)
+void wrbuf_puts(WRBUF b, const char *buf)
{
wrbuf_write(b, buf, strlen(buf));
- return 0;
}
void wrbuf_vputs(const char *buf, void *client_data)
wrbuf_write((WRBUF) client_data, buf, strlen(buf));
}
-int wrbuf_puts_replace_char(WRBUF b, const char *buf,
+void wrbuf_puts_replace_char(WRBUF b, const char *buf,
const char from, const char to)
{
while(*buf)
wrbuf_putc(b, *buf);
buf++;
}
- return 0;
}
void wrbuf_chop_right(WRBUF b)
}
}
-int wrbuf_xmlputs(WRBUF b, const char *cp)
+void wrbuf_xmlputs(WRBUF b, const char *cp)
{
- return wrbuf_xmlputs_n(b, cp, strlen(cp));
+ wrbuf_xmlputs_n(b, cp, strlen(cp));
}
-int wrbuf_xmlputs_n(WRBUF b, const char *cp, int size)
+void wrbuf_xmlputs_n(WRBUF b, const char *cp, size_t size)
{
- while (--size >= 0)
+ for (; size; size--)
{
/* only TAB,CR,LF of ASCII CTRL are allowed in XML 1.0! */
if (*cp >= 0 && *cp <= 31)
}
cp++;
}
- return 0;
}
void wrbuf_printf(WRBUF b, const char *fmt, ...)
va_end(ap);
}
-static int wrbuf_iconv_write_x(WRBUF b, yaz_iconv_t cd, const char *buf,
- int size, int cdata)
+static void wrbuf_iconv_write_x(WRBUF b, yaz_iconv_t cd, const char *buf,
+ size_t size, int cdata)
{
if (cd)
{
else
wrbuf_write(b, buf, size);
}
- return wrbuf_len(b);
}
-int wrbuf_iconv_write(WRBUF b, yaz_iconv_t cd, const char *buf, int size)
+void wrbuf_iconv_write(WRBUF b, yaz_iconv_t cd, const char *buf, size_t size)
{
- return wrbuf_iconv_write_x(b, cd, buf, size, 0);
+ wrbuf_iconv_write_x(b, cd, buf, size, 0);
}
-int wrbuf_iconv_puts(WRBUF b, yaz_iconv_t cd, const char *strz)
+void wrbuf_iconv_puts(WRBUF b, yaz_iconv_t cd, const char *strz)
{
- return wrbuf_iconv_write(b, cd, strz, strlen(strz));
+ wrbuf_iconv_write(b, cd, strz, strlen(strz));
}
-int wrbuf_iconv_putchar(WRBUF b, yaz_iconv_t cd, int ch)
+void wrbuf_iconv_putchar(WRBUF b, yaz_iconv_t cd, int ch)
{
char buf[1];
buf[0] = ch;
- return wrbuf_iconv_write(b, cd, buf, 1);
+ wrbuf_iconv_write(b, cd, buf, 1);
}
-int wrbuf_iconv_write_cdata(WRBUF b, yaz_iconv_t cd, const char *buf, int size)
+void wrbuf_iconv_write_cdata(WRBUF b, yaz_iconv_t cd, const char *buf, size_t size)
{
- return wrbuf_iconv_write_x(b, cd, buf, size, 1);
+ wrbuf_iconv_write_x(b, cd, buf, size, 1);
}
-int wrbuf_iconv_puts_cdata(WRBUF b, yaz_iconv_t cd, const char *strz)
+void wrbuf_iconv_puts_cdata(WRBUF b, yaz_iconv_t cd, const char *strz)
{
- return wrbuf_iconv_write_x(b, cd, strz, strlen(strz), 1);
+ wrbuf_iconv_write_x(b, cd, strz, strlen(strz), 1);
}
void wrbuf_iconv_reset(WRBUF b, yaz_iconv_t cd)