Fix XML config GFS do not fail if port is in use YAZ-709
[yaz-moved-to-github.git] / src / wrbuf.c
index 06e49de..a51adee 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2011 Index Data
+ * Copyright (C) 1995-2013 Index Data
  * See the file LICENSE for details.
  */
 
@@ -74,12 +74,29 @@ void wrbuf_write(WRBUF b, const char *buf, size_t size)
     b->pos += size;
 }
 
+void wrbuf_insert(WRBUF b, size_t pos, const char *buf, size_t size)
+{
+    if (size <= 0 || pos > b->pos)
+        return;
+    if (b->pos + size >= b->size)
+        wrbuf_grow(b, size);
+    memmove(b->buf + pos + size, b->buf + pos, b->pos - pos);
+    memcpy(b->buf + pos, buf, size);
+    b->pos += size;
+}
+
 void wrbuf_puts(WRBUF b, const char *buf)
 {
     wrbuf_write(b, buf, strlen(buf));
 }
 
-void wrbuf_puts_replace_char(WRBUF b, const char *buf, 
+void wrbuf_vp_puts(const char *buf, void *client_data)
+{
+    WRBUF b = (WRBUF) client_data;
+    wrbuf_puts(b, buf);
+}
+
+void wrbuf_puts_replace_char(WRBUF b, const char *buf,
                             const char from, const char to)
 {
     while(*buf)