Sun, 03 Jul 2011 13:13:36 -0700
context: Support ECDH cipher suites, where applicable
0 | 1 | #ifndef IO_H |
2 | #define IO_H | |
3 | /*=========================================================================*\ | |
4 | * LuaSocket 2.0.2 | |
5 | * Copyright (C) 2004-2007 Diego Nehab | |
6 | * | |
7 | * Input/Output abstraction | |
8 | * | |
9 | * This module defines the interface that LuaSocket expects from the | |
10 | * transport layer for streamed input/output. The idea is that if any | |
11 | * transport implements this interface, then the buffer.c functions | |
12 | * automatically work on it. | |
13 | * | |
14 | * The module socket.h implements this interface, and thus the module tcp.h | |
15 | * is very simple. | |
16 | * | |
17 | * RCS ID: $Id: io.h 6 2006-04-30 20:33:05Z brunoos $ | |
18 | \*=========================================================================*/ | |
19 | #include <stdio.h> | |
20 | #include <lua.h> | |
21 | ||
22 | #include "timeout.h" | |
23 | ||
24 | /* IO error codes */ | |
25 | enum { | |
26 | IO_DONE = 0, /* operation completed successfully */ | |
27 | IO_TIMEOUT = -1, /* operation timed out */ | |
28 | IO_CLOSED = -2, /* the connection has been closed */ | |
29 | IO_UNKNOWN = -3, /* Unknown error */ | |
30 | IO_SSL = -4 /* SSL error */ | |
31 | }; | |
32 | ||
33 | /* interface to error message function */ | |
34 | typedef const char *(*p_error) ( | |
35 | void *ctx, /* context needed by send */ | |
36 | int err /* error code */ | |
37 | ); | |
38 | ||
39 | /* interface to send function */ | |
40 | typedef int (*p_send) ( | |
41 | void *ctx, /* context needed by send */ | |
42 | const char *data, /* pointer to buffer with data to send */ | |
43 | size_t count, /* number of bytes to send from buffer */ | |
44 | size_t *sent, /* number of bytes sent uppon return */ | |
45 | p_timeout tm /* timeout control */ | |
46 | ); | |
47 | ||
48 | /* interface to recv function */ | |
49 | typedef int (*p_recv) ( | |
50 | void *ctx, /* context needed by recv */ | |
51 | char *data, /* pointer to buffer where data will be writen */ | |
52 | size_t count, /* number of bytes to receive into buffer */ | |
53 | size_t *got, /* number of bytes received uppon return */ | |
54 | p_timeout tm /* timeout control */ | |
55 | ); | |
56 | ||
57 | /* IO driver definition */ | |
58 | typedef struct t_io_ { | |
59 | void *ctx; /* context needed by send/recv */ | |
60 | p_send send; /* send function pointer */ | |
61 | p_recv recv; /* receive function pointer */ | |
62 | p_error error; /* strerror function */ | |
63 | } t_io; | |
64 | typedef t_io *p_io; | |
65 | ||
66 | void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx); | |
67 | const char *io_strerror(int err); | |
68 | ||
69 | #endif /* IO_H */ | |
70 |