X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fwrbuf.c;h=973f0802a11195ba11f31bb84ea9aed1007a50dd;hb=3eba413ef7e80467c7831731a8e35c733e447c47;hp=b180ef0b17e9422d22df6314a201060acd785d8c;hpb=85aafc49077214164bbdc2b84f247343ef9c3696;p=yaz-moved-to-github.git diff --git a/src/wrbuf.c b/src/wrbuf.c index b180ef0..973f080 100644 --- a/src/wrbuf.c +++ b/src/wrbuf.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: wrbuf.c,v 1.14 2007-01-06 15:32:46 adam Exp $ + * $Id: wrbuf.c,v 1.17 2007-03-18 12:59:56 adam Exp $ */ /** @@ -20,6 +20,7 @@ #include #include +#include #include WRBUF wrbuf_alloc(void) @@ -159,16 +160,7 @@ void wrbuf_printf(WRBUF b, const char *fmt, ...) char buf[4096]; va_start(ap, fmt); -#ifdef WIN32 - _vsnprintf(buf, sizeof(buf)-1, fmt, ap); -#else -/* !WIN32 */ -#if HAVE_VSNPRINTF - vsnprintf(buf, sizeof(buf)-1, fmt, ap); -#else - vsprintf(buf, fmt, ap); -#endif -#endif + yaz_vsnprintf(buf, sizeof(buf)-1, fmt, ap); wrbuf_puts (b, buf); va_end(ap); @@ -232,6 +224,20 @@ int wrbuf_iconv_write_cdata(WRBUF b, yaz_iconv_t cd, const char *buf, int size) return wrbuf_iconv_write_x(b, cd, buf, size, 1); } +const char *wrbuf_cstr(WRBUF b) +{ + wrbuf_write(b, "", 1); /* '\0'-terminate as well */ + (b->pos)--; /* don't include '\0' in count */ + return b->buf; +} + +void wrbuf_cut_right(WRBUF b, size_t no_to_remove) +{ + if (no_to_remove > b->pos) + no_to_remove = b->pos; + b->pos = b->pos - no_to_remove; +} + /* * Local variables: * c-basic-offset: 4