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
219
cefec18b8268 some of the lib/transport stuff compiles
Tero Marttila <terom@fixme.fi>
parents: 196
diff changeset
     1
#ifndef LIBQMSK_TRANSPORT_TEST_H
cefec18b8268 some of the lib/transport stuff compiles
Tero Marttila <terom@fixme.fi>
parents: 196
diff changeset
     2
#define LIBQMSK_TRANSPORT_TEST_H
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
/**
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
 * @file
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
 *
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
     7
 * Dummy transport implemention for local testing.
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
 */
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
     9
#include "transport.h"
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
/**
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    12
 * The opaque transport state
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
 */
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    14
struct transport_test;
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
/**
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    17
 * Construct a new, empty, connected transport_test.
41
40f7aa051acb add line_proto test, enhance others
Tero Marttila <terom@fixme.fi>
parents: 40
diff changeset
    18
 */
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    19
struct transport_test* transport_test_create (struct transport_info *info);
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
/**
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    22
 * A transport_test is a valid transport, this performs the cast
41
40f7aa051acb add line_proto test, enhance others
Tero Marttila <terom@fixme.fi>
parents: 40
diff changeset
    23
 */
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    24
transport_t* transport_test_cast (struct transport_test *tp);
41
40f7aa051acb add line_proto test, enhance others
Tero Marttila <terom@fixme.fi>
parents: 40
diff changeset
    25
40f7aa051acb add line_proto test, enhance others
Tero Marttila <terom@fixme.fi>
parents: 40
diff changeset
    26
/**
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    27
 * Invoke the transport's user callbacks for the given event mask, unless masked out.
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    28
 */
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    29
void transport_test_event (struct transport_test *tp, short what);
41
40f7aa051acb add line_proto test, enhance others
Tero Marttila <terom@fixme.fi>
parents: 40
diff changeset
    30
40f7aa051acb add line_proto test, enhance others
Tero Marttila <terom@fixme.fi>
parents: 40
diff changeset
    31
/**
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    32
 * Adds a data buffer to the recieve buffer.
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    33
 *
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    34
 * The given data is copied.
42
13cfc41f76a7 test async operation
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    35
 *
13cfc41f76a7 test async operation
Tero Marttila <terom@fixme.fi>
parents: 41
diff changeset
    36
 * If events are enabled, they are triggered.
41
40f7aa051acb add line_proto test, enhance others
Tero Marttila <terom@fixme.fi>
parents: 40
diff changeset
    37
 */
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    38
void transport_test_push_buf (struct transport_test *tp, const char *buf, size_t len);
43
42f5dc680930 improve irc_conn test
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    39
42f5dc680930 improve irc_conn test
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    40
/**
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    41
 * Add a string to the recieve buffer using transport_test_push_buf()
46
0c13bca53ae1 add irc_net_error, and improve test_irc_net to cover it as well
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    42
 */
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    43
void transport_test_push_str (struct transport_test *tp, const char *str);
46
0c13bca53ae1 add irc_net_error, and improve test_irc_net to cover it as well
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    44
0c13bca53ae1 add irc_net_error, and improve test_irc_net to cover it as well
Tero Marttila <terom@fixme.fi>
parents: 43
diff changeset
    45
/**
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    46
 * Maximum length of a formatted string pushed
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    47
 */
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    48
#define TRANSPORT_TEST_FMT_MAX 4096
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    49
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    50
/**
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    51
 * Add a formatted string to the recieve buffer
43
42f5dc680930 improve irc_conn test
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    52
 *
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    53
 * @see TRANSPORT_TEST_FMT_MAX
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    54
 */
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    55
void transport_test_push_fmt (struct transport_test *tp, const char *fmt, ...);
40
51678c7eae03 add sock_test module and some basic initial tests
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    56
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    57
/**
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    58
 * Set EOF on recv.
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    59
 */
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    60
void transport_test_push_eof (struct transport_test *tp);
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    61
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    62
/**
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    63
 * Get the send buffer contents as a single buffer, free() after use.
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    64
 *
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    65
 * This clears the send buffer, so this doesn't return the same data twice.
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    66
 */
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    67
void transport_test_pull_buf (struct transport_test *tp, char **buf_ptr, size_t *len_ptr);
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    68
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    69
/**
196
873796250c60 implement msg_proto and associated test, fix misc. other bugs (including changing error_info::code to a signed int\!)
Tero Marttila <terom@fixme.fi>
parents: 166
diff changeset
    70
 * Send async error
873796250c60 implement msg_proto and associated test, fix misc. other bugs (including changing error_info::code to a signed int\!)
Tero Marttila <terom@fixme.fi>
parents: 166
diff changeset
    71
 */
873796250c60 implement msg_proto and associated test, fix misc. other bugs (including changing error_info::code to a signed int\!)
Tero Marttila <terom@fixme.fi>
parents: 166
diff changeset
    72
void transport_test_async_error (struct transport_test *tp, const error_t *err);
873796250c60 implement msg_proto and associated test, fix misc. other bugs (including changing error_info::code to a signed int\!)
Tero Marttila <terom@fixme.fi>
parents: 166
diff changeset
    73
873796250c60 implement msg_proto and associated test, fix misc. other bugs (including changing error_info::code to a signed int\!)
Tero Marttila <terom@fixme.fi>
parents: 166
diff changeset
    74
/**
166
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    75
 * Destroy the transport buffer, releasing any buffers we allocated ourself
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    76
 */
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    77
void transport_test_destroy (struct transport_test *tp);
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    78
cb8cb023cf06 replace old sock_test with new transport_test
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    79
#endif /* TRANSPORT_TEST_H */