diff options
Diffstat (limited to 'vendor/luasocket/src/io.h')
-rw-r--r-- | vendor/luasocket/src/io.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/vendor/luasocket/src/io.h b/vendor/luasocket/src/io.h new file mode 100644 index 00000000..b8a54df6 --- /dev/null +++ b/vendor/luasocket/src/io.h | |||
@@ -0,0 +1,70 @@ | |||
1 | #ifndef IO_H | ||
2 | #define IO_H | ||
3 | /*=========================================================================*\ | ||
4 | * Input/Output abstraction | ||
5 | * LuaSocket toolkit | ||
6 | * | ||
7 | * This module defines the interface that LuaSocket expects from the | ||
8 | * transport layer for streamed input/output. The idea is that if any | ||
9 | * transport implements this interface, then the buffer.c functions | ||
10 | * automatically work on it. | ||
11 | * | ||
12 | * The module socket.h implements this interface, and thus the module tcp.h | ||
13 | * is very simple. | ||
14 | \*=========================================================================*/ | ||
15 | #include "luasocket.h" | ||
16 | #include "timeout.h" | ||
17 | |||
18 | /* IO error codes */ | ||
19 | enum { | ||
20 | IO_DONE = 0, /* operation completed successfully */ | ||
21 | IO_TIMEOUT = -1, /* operation timed out */ | ||
22 | IO_CLOSED = -2, /* the connection has been closed */ | ||
23 | IO_UNKNOWN = -3 | ||
24 | }; | ||
25 | |||
26 | /* interface to error message function */ | ||
27 | typedef const char *(*p_error) ( | ||
28 | void *ctx, /* context needed by send */ | ||
29 | int err /* error code */ | ||
30 | ); | ||
31 | |||
32 | /* interface to send function */ | ||
33 | typedef int (*p_send) ( | ||
34 | void *ctx, /* context needed by send */ | ||
35 | const char *data, /* pointer to buffer with data to send */ | ||
36 | size_t count, /* number of bytes to send from buffer */ | ||
37 | size_t *sent, /* number of bytes sent uppon return */ | ||
38 | p_timeout tm /* timeout control */ | ||
39 | ); | ||
40 | |||
41 | /* interface to recv function */ | ||
42 | typedef int (*p_recv) ( | ||
43 | void *ctx, /* context needed by recv */ | ||
44 | char *data, /* pointer to buffer where data will be writen */ | ||
45 | size_t count, /* number of bytes to receive into buffer */ | ||
46 | size_t *got, /* number of bytes received uppon return */ | ||
47 | p_timeout tm /* timeout control */ | ||
48 | ); | ||
49 | |||
50 | /* IO driver definition */ | ||
51 | typedef struct t_io_ { | ||
52 | void *ctx; /* context needed by send/recv */ | ||
53 | p_send send; /* send function pointer */ | ||
54 | p_recv recv; /* receive function pointer */ | ||
55 | p_error error; /* strerror function */ | ||
56 | } t_io; | ||
57 | typedef t_io *p_io; | ||
58 | |||
59 | #ifndef _WIN32 | ||
60 | #pragma GCC visibility push(hidden) | ||
61 | #endif | ||
62 | |||
63 | void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx); | ||
64 | const char *io_strerror(int err); | ||
65 | |||
66 | #ifndef _WIN32 | ||
67 | #pragma GCC visibility pop | ||
68 | #endif | ||
69 | |||
70 | #endif /* IO_H */ | ||