src/lib/transport_test.h
author Tero Marttila <terom@fixme.fi>
Thu, 28 May 2009 01:17:36 +0300
branchnew-lib-errors
changeset 219 cefec18b8268
parent 196 src/transport_test.h@873796250c60
permissions -rw-r--r--
some of the lib/transport stuff compiles
#ifndef LIBQMSK_TRANSPORT_TEST_H
#define LIBQMSK_TRANSPORT_TEST_H

/**
 * @file
 *
 * Dummy transport implemention for local testing.
 */
#include "transport.h"

/**
 * The opaque transport state
 */
struct transport_test;

/**
 * Construct a new, empty, connected transport_test.
 */
struct transport_test* transport_test_create (struct transport_info *info);

/**
 * A transport_test is a valid transport, this performs the cast
 */
transport_t* transport_test_cast (struct transport_test *tp);

/**
 * Invoke the transport's user callbacks for the given event mask, unless masked out.
 */
void transport_test_event (struct transport_test *tp, short what);

/**
 * Adds a data buffer to the recieve buffer.
 *
 * The given data is copied.
 *
 * If events are enabled, they are triggered.
 */
void transport_test_push_buf (struct transport_test *tp, const char *buf, size_t len);

/**
 * Add a string to the recieve buffer using transport_test_push_buf()
 */
void transport_test_push_str (struct transport_test *tp, const char *str);

/**
 * Maximum length of a formatted string pushed
 */
#define TRANSPORT_TEST_FMT_MAX 4096

/**
 * Add a formatted string to the recieve buffer
 *
 * @see TRANSPORT_TEST_FMT_MAX
 */
void transport_test_push_fmt (struct transport_test *tp, const char *fmt, ...);

/**
 * Set EOF on recv.
 */
void transport_test_push_eof (struct transport_test *tp);

/**
 * Get the send buffer contents as a single buffer, free() after use.
 *
 * This clears the send buffer, so this doesn't return the same data twice.
 */
void transport_test_pull_buf (struct transport_test *tp, char **buf_ptr, size_t *len_ptr);

/**
 * Send async error
 */
void transport_test_async_error (struct transport_test *tp, const error_t *err);

/**
 * Destroy the transport buffer, releasing any buffers we allocated ourself
 */
void transport_test_destroy (struct transport_test *tp);

#endif /* TRANSPORT_TEST_H */