diff options
Diffstat (limited to 'src/ssl.c')
| -rw-r--r-- | src/ssl.c | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/src/ssl.c b/src/ssl.c deleted file mode 100644 index 8e2ce00..0000000 --- a/src/ssl.c +++ /dev/null | |||
| @@ -1,70 +0,0 @@ | |||
| 1 | /*=========================================================================*\ | ||
| 2 | * Simple client SSL support | ||
| 3 | * LuaSocket toolkit | ||
| 4 | * | ||
| 5 | * RCS ID: $Id$ | ||
| 6 | \*=========================================================================*/ | ||
| 7 | #include <lua.h> | ||
| 8 | #include <lauxlib.h> | ||
| 9 | |||
| 10 | #include "ssl.h" | ||
| 11 | |||
| 12 | /*=========================================================================*\ | ||
| 13 | * Internal function prototypes | ||
| 14 | \*=========================================================================*/ | ||
| 15 | static int global_wrap(lua_State *L); | ||
| 16 | |||
| 17 | /* functions in library namespace */ | ||
| 18 | static luaL_reg func[] = { | ||
| 19 | {"wrap", global_create}, | ||
| 20 | {NULL, NULL} | ||
| 21 | }; | ||
| 22 | |||
| 23 | static luaL_reg wrap[] = { | ||
| 24 | {"__tostring", aux_tostring}, | ||
| 25 | {"__gc", meth_close}, | ||
| 26 | {"close", meth_close}, | ||
| 27 | {"receive", meth_receive}, | ||
| 28 | {"send", meth_send}, | ||
| 29 | {NULL, NULL} | ||
| 30 | }; | ||
| 31 | |||
| 32 | static luaL_reg owned[] = { | ||
| 33 | {"__tostring", aux_tostring}, | ||
| 34 | {NULL, NULL} | ||
| 35 | }; | ||
| 36 | |||
| 37 | /*-------------------------------------------------------------------------*\ | ||
| 38 | * Initializes module | ||
| 39 | \*-------------------------------------------------------------------------*/ | ||
| 40 | int ssl_open(lua_State *L) | ||
| 41 | { | ||
| 42 | aux_newclass(L, "ssl{wraper}", wrap); | ||
| 43 | aux_newclass(L, "ssl{owned}", owned); | ||
| 44 | lua_pushstring(L, "ssl") | ||
| 45 | lua_newtable(L); | ||
| 46 | luaL_openlib(L, NULL, func, 0); | ||
| 47 | lua_settable(L, -3); | ||
| 48 | return 0; | ||
| 49 | } | ||
| 50 | |||
| 51 | /*=========================================================================*\ | ||
| 52 | * Library functions | ||
| 53 | \*=========================================================================*/ | ||
| 54 | /*-------------------------------------------------------------------------*\ | ||
| 55 | * Wraps a tcp object into an SSL object | ||
| 56 | \*-------------------------------------------------------------------------*/ | ||
| 57 | static int global_wrap(lua_State *L) { | ||
| 58 | p_tcp tcp = (p_tcp) aux_checkclass(L, "tcp{client}", 1); | ||
| 59 | /* change class of tcp object */ | ||
| 60 | aux_setclass(L, "ssl{owned}", 1); | ||
| 61 | /* create wrapper */ | ||
| 62 | p_wrap wrap = (p_wrap) lua_newuserdata(L, sizeof(t_wrap)); | ||
| 63 | /* lock reference */ | ||
| 64 | lua_pushvalue(L, 1); | ||
| 65 | wrap->ref = lua_ref(L, 1); | ||
| 66 | /* initialize wrapper */ | ||
| 67 | wrap->tcp = tcp; | ||
| 68 | io_init(&tcp->io, wrap_send, wrap_recv, wrap); | ||
| 69 | return 1; | ||
| 70 | } | ||
