X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=util%2Fwrbuf.c;h=d6d44a1b638212b975d633c8803eea86f948af32;hp=c948dc1180941b9eb24513de58accab45d043351;hb=59fc25662cfb2144a8f9173616aa70a1da9e4f44;hpb=044d170f0a963555486df54653cd2fdc5815928b diff --git a/util/wrbuf.c b/util/wrbuf.c index c948dc1..d6d44a1 100644 --- a/util/wrbuf.c +++ b/util/wrbuf.c @@ -1,10 +1,25 @@ /* - * Copyright (c) 1995, Index Data. + * Copyright (c) 1995-2000, Index Data. * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: wrbuf.c,v $ - * Revision 1.4 1998-02-11 11:53:36 adam + * Revision 1.9 2000-02-29 13:44:55 adam + * Check for config.h (currently not generated). + * + * 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 @@ -23,10 +38,14 @@ * Growing buffer for writing various stuff. */ +#if HAVE_CONFIG_H +#include +#endif + #include #include -#include +#include WRBUF wrbuf_alloc(void) { @@ -69,11 +88,20 @@ int wrbuf_grow(WRBUF b, int minsize) return 0; } -int wrbuf_write(WRBUF b, char *buf, int size) +int wrbuf_write(WRBUF b, const char *buf, int size) { + if (size <= 0) + return 0; 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) +{ + wrbuf_write(b, buf, strlen(buf)+1); /* '\0'-terminate as well */ + (b->pos)--; /* don't include '\0' in count */ + return 0; +}