--- a/src/sock_test.h Thu Mar 12 20:00:48 2009 +0200
+++ b/src/sock_test.h Thu Mar 12 21:12:48 2009 +0200
@@ -7,6 +7,7 @@
* Dummy sock_stream implemention for local testing.
*/
#include "sock_internal.h"
+#include <stdbool.h>
/**
* IO vector
@@ -29,8 +30,8 @@
/** The number of io_vecs */
size_t count;
- /** Current vector */
- struct io_vec *vec;
+ /** Current read/write vector */
+ struct io_vec *read_vec, *write_vec;
/** Offset into current vector */
size_t off;
@@ -45,6 +46,12 @@
/** The send/recieve buffers */
struct io_buf send_buf, recv_buf;
+
+ /** non-blocking mode? */
+ bool nonblocking;
+
+ /** No more data is going to be added, return EOF once all the rest is consumed */
+ bool eof;
};
/**
@@ -53,16 +60,33 @@
#define SOCK_TEST_BASE(sock_ptr) (&(sock_ptr)->base)
/**
+ * Get the sock_stream.err pointer from a sock_tcp pointer
+ */
+#define SOCK_TEST_ERR(sock_ptr) SOCK_ERR(SOCK_TEST_BASE(sock_ptr))
+
+/**
* A dummy stream socket intended for testing purposes.
*/
struct sock_test* sock_test_create (void);
/**
+ * Destroy the sock buffer, releasing any resource we allocated ourself
+ */
+void sock_test_destroy (struct sock_test *sock);
+
+/**
* Set the recieve buffer contents.
*
- * The data is not copied, but the vectors are stored as-is.
+ * The vectors themselves are copied, but the data they contain is not.
+ *
+ * If the EOF flag is given, it indicates that no more data will be added, otherwise the eof status is unchanged.
*/
-void sock_test_set_recv_buffer (struct sock_test *sock, struct io_vec *vecs, size_t count);
+void sock_test_set_recv_buffer (struct sock_test *sock, struct io_vec *vecs, size_t count, bool eof);
+
+/**
+ * Add some data to the recieve buffer
+ */
+void sock_test_add_recv_vec (struct sock_test *sock, struct io_vec vec);
/**
* Get the send buffer contents as a single string, free() after use if you care about that