src/lib/transport_test.h
branchnew-lib-errors
changeset 219 cefec18b8268
parent 196 873796250c60
equal deleted inserted replaced
218:5229a5d098b2 219:cefec18b8268
       
     1 #ifndef LIBQMSK_TRANSPORT_TEST_H
       
     2 #define LIBQMSK_TRANSPORT_TEST_H
       
     3 
       
     4 /**
       
     5  * @file
       
     6  *
       
     7  * Dummy transport implemention for local testing.
       
     8  */
       
     9 #include "transport.h"
       
    10 
       
    11 /**
       
    12  * The opaque transport state
       
    13  */
       
    14 struct transport_test;
       
    15 
       
    16 /**
       
    17  * Construct a new, empty, connected transport_test.
       
    18  */
       
    19 struct transport_test* transport_test_create (struct transport_info *info);
       
    20 
       
    21 /**
       
    22  * A transport_test is a valid transport, this performs the cast
       
    23  */
       
    24 transport_t* transport_test_cast (struct transport_test *tp);
       
    25 
       
    26 /**
       
    27  * Invoke the transport's user callbacks for the given event mask, unless masked out.
       
    28  */
       
    29 void transport_test_event (struct transport_test *tp, short what);
       
    30 
       
    31 /**
       
    32  * Adds a data buffer to the recieve buffer.
       
    33  *
       
    34  * The given data is copied.
       
    35  *
       
    36  * If events are enabled, they are triggered.
       
    37  */
       
    38 void transport_test_push_buf (struct transport_test *tp, const char *buf, size_t len);
       
    39 
       
    40 /**
       
    41  * Add a string to the recieve buffer using transport_test_push_buf()
       
    42  */
       
    43 void transport_test_push_str (struct transport_test *tp, const char *str);
       
    44 
       
    45 /**
       
    46  * Maximum length of a formatted string pushed
       
    47  */
       
    48 #define TRANSPORT_TEST_FMT_MAX 4096
       
    49 
       
    50 /**
       
    51  * Add a formatted string to the recieve buffer
       
    52  *
       
    53  * @see TRANSPORT_TEST_FMT_MAX
       
    54  */
       
    55 void transport_test_push_fmt (struct transport_test *tp, const char *fmt, ...);
       
    56 
       
    57 /**
       
    58  * Set EOF on recv.
       
    59  */
       
    60 void transport_test_push_eof (struct transport_test *tp);
       
    61 
       
    62 /**
       
    63  * Get the send buffer contents as a single buffer, free() after use.
       
    64  *
       
    65  * This clears the send buffer, so this doesn't return the same data twice.
       
    66  */
       
    67 void transport_test_pull_buf (struct transport_test *tp, char **buf_ptr, size_t *len_ptr);
       
    68 
       
    69 /**
       
    70  * Send async error
       
    71  */
       
    72 void transport_test_async_error (struct transport_test *tp, const error_t *err);
       
    73 
       
    74 /**
       
    75  * Destroy the transport buffer, releasing any buffers we allocated ourself
       
    76  */
       
    77 void transport_test_destroy (struct transport_test *tp);
       
    78 
       
    79 #endif /* TRANSPORT_TEST_H */