aboutsummaryrefslogtreecommitdiff
path: root/buffer_copy.c
diff options
context:
space:
mode:
Diffstat (limited to 'buffer_copy.c')
-rw-r--r--buffer_copy.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/buffer_copy.c b/buffer_copy.c
new file mode 100644
index 0000000..dc4d4b1
--- /dev/null
+++ b/buffer_copy.c
@@ -0,0 +1,16 @@
+#include "buffer.h"
+
+int buffer_copy(buffer *bout,buffer *bin)
+{
+ int n;
+ char *x;
+
+ for (;;) {
+ n = buffer_feed(bin);
+ if (n < 0) return -2;
+ if (!n) return 0;
+ x = buffer_PEEK(bin);
+ if (buffer_put(bout,x,n) == -1) return -3;
+ buffer_SEEK(bin,n);
+ }
+}