src/sock_test.h
branchnew-transport
changeset 166 cb8cb023cf06
parent 165 b3e95108c884
child 167 0d2d8ca879d8
--- a/src/sock_test.h	Sun May 03 17:18:16 2009 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-#ifndef SOCK_TEST_H
-#define SOCK_TEST_H
-
-/**
- * @file
- *
- * Dummy sock_stream implemention for local testing.
- */
-#include "sock_internal.h"
-#include <stdbool.h>
-
-/**
- * Simple IO vector
- */
-struct io_vec {
-    /** The buffer */
-    char *buf;
-
-    /** Buffer size */
-    size_t len;
-};
-
-/**
- * Simple vectored IO-buffer
- */
-struct io_buf {
-    /** The array of buffer-vectors, {NULL}-terminated */
-    struct io_vec *vecs;
-
-    /** The number of io_vecs */
-    size_t count;
-
-    /** Current read/write vector */
-    struct io_vec *read_vec, *write_vec;
-
-    /** Offset into current vector */
-    size_t off;
-};
-
-/**
- * A dummy sock_stream implementation intended for testing purposes.
- */
-struct sock_test {
-    /** The base struct for sock_stream_* functions */
-    struct sock_stream base;
-
-    /** 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;
-
-    /** event flags */
-    int ev_mask;
-};
-
-/**
- * Get a sock_stream pointer from a sock_tcp pointer
- */
-#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 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, bool eof);
-
-/**
- * Add some data to the recieve buffer.
- *
- * If events are enabled, they are triggered.
- */
-void sock_test_add_recv_vec (struct sock_test *sock, struct io_vec vec);
-
-/**
- * Add a string to the recieve buffer using sock_test_add_recv_vec()
- */
-void sock_test_add_recv_str (struct sock_test *sock, const char *str);
-
-/**
- * Set EOF on recv, and trigger events.
- */
-void sock_test_set_recv_eof (struct sock_test *sock);
-
-/**
- * Get the send buffer contents as a single string, free() after use if you care about that.
- *
- * Clears the send buffer, so this doesn't return the same data twice.
- */
-void sock_test_get_send_data (struct sock_test *sock, char **buf, size_t *len);
-
-#endif