X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fwrbuf.c;h=c3fea1f5d40e089a6685e82a3ab1e44a864aacee;hb=12e68873046de1fc08b5589891914ec2cdc3d453;hp=b3b4b8b3f5e9c854c42d7aa1ec1f2f6c982f614d;hpb=d9ee01635f03f9095a66f71b73580560d48798e8;p=yaz-moved-to-github.git diff --git a/util/wrbuf.c b/util/wrbuf.c index b3b4b8b..c3fea1f 100644 --- a/util/wrbuf.c +++ b/util/wrbuf.c @@ -1,42 +1,23 @@ /* - * Copyright (c) 1995-1999, Index Data. + * Copyright (c) 1995-2002, Index Data. * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Log: wrbuf.c,v $ - * Revision 1.8 1999-11-30 13:47:12 adam - * Improved installation. Moved header files to include/yaz. - * - * Revision 1.7 1999/11/03 09:05:56 adam - * Implemented wrbuf_puts. - * - * Revision 1.6 1999/10/28 11:36:40 adam - * wrbuf_write allows zero buffer length. - * - * Revision 1.5 1999/08/27 09:40:32 adam - * Renamed logf function to yaz_log. Removed VC++ project files. - * - * Revision 1.4 1998/02/11 11:53:36 adam - * Changed code so that it compiles as C++. - * - * Revision 1.3 1997/05/01 15:08:15 adam - * Added log_mask_str_x routine. - * - * Revision 1.2 1995/11/01 13:55:06 quinn - * Minor adjustments - * - * Revision 1.1 1995/10/06 08:51:25 quinn - * Added Write-buffer. - * - * + * $Id: wrbuf.c,v 1.11 2002-10-22 14:40:21 adam Exp $ */ /* * Growing buffer for writing various stuff. */ +#if HAVE_CONFIG_H +#include +#endif + +#include #include #include +#include #include @@ -98,3 +79,25 @@ int wrbuf_puts(WRBUF b, const char *buf) (b->pos)--; /* don't include '\0' in count */ return 0; } + +void wrbuf_printf(WRBUF b, const char *fmt, ...) +{ + va_list ap; + 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 + wrbuf_puts (b, buf); + + va_end(ap); +} +