* (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.23 2007-01-06 16:05:24 adam Exp $ */
+/* $Id: wrbuf.h,v 1.24 2007-03-18 12:59:56 adam Exp $ */
/**
* \file wrbuf.h
YAZ_BEGIN_CDECL
+/** \brief string buffer */
typedef struct wrbuf
{
char *buf;
int size;
} wrbuf, *WRBUF;
+/** \brief allocate / construct WRBUF */
YAZ_EXPORT WRBUF wrbuf_alloc(void);
+
+/** \brief free WRBUF and possibly its buffer */
YAZ_EXPORT void wrbuf_free(WRBUF b, int free_buf);
+
+/** \brief destroy WRBUF and its buffer */
YAZ_EXPORT void wrbuf_destroy(WRBUF b);
+
+/** \brief empty WRBUF content */
YAZ_EXPORT void wrbuf_rewind(WRBUF b);
+
+/** \brief grow WRBUF larger */
YAZ_EXPORT int wrbuf_grow(WRBUF b, int minsize);
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);
YAZ_EXPORT void wrbuf_chop_right(WRBUF b);
+/** \brief cut size of WRBUF */
+YAZ_EXPORT void wrbuf_cut_right(WRBUF b, size_t no_to_remove);
+
#define wrbuf_len(b) ((b)->pos)
#define wrbuf_buf(b) ((b)->buf)
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: wrbuf.c,v 1.16 2007-02-23 10:15:01 adam Exp $
+ * $Id: wrbuf.c,v 1.17 2007-03-18 12:59:56 adam Exp $
*/
/**
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