summaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
authorjakob <jakob@memeware.net>2017-05-14 19:07:06 -0400
committerjakob <jakob@memeware.net>2017-05-14 19:07:06 -0400
commit2ba0b505ce1ee748f42a85f7e27906737fa47fc8 (patch)
treeeacdebd8beae803b8c04c41d93ccb0dc8d45e35a /src/io.c
parent41a7566c121a865b460649390a75473ac71eff1f (diff)
Initial data dumping functionality.
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/io.c b/src/io.c
index d282edc..cd6e8a3 100644
--- a/src/io.c
+++ b/src/io.c
@@ -91,7 +91,7 @@ void stream_dump(FILE *fp, struct stream *s, size_t n) {
/* Copies `n` bytes into the given stream from the memory area specified
by `src`. The stream's cursor is advanced appropriately. */
void stream_write(struct stream *s, void *src, size_t n) {
- if (s->_cur + n > s->_start + s->len) {
+ while (s->_cur + n > s->_start + s->len) {
ptrdiff_t dist = (uintptr_t) s->_cur - (uintptr_t) s->_start;
switch(s->_loc) {
case HEAP:
@@ -105,6 +105,12 @@ void stream_write(struct stream *s, void *src, size_t n) {
}
+/* Concatenats the contents of `src` onto `dst`. */
+void stream_concat(struct stream *dst, struct stream *src, size_t n) {
+ stream_write(dst, src->_cur, n);
+}
+
+
/* Applies an initial and primary key to the given stream, effectively
encrypting or decrypting it. */
void stream_xor(struct stream *s, uint8_t initial, uint8_t primary) {