summaryrefslogtreecommitdiffhomepage
path: root/libs/nixio/src/tls-socket.c
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2009-04-21 16:26:45 +0000
committerSteven Barth <steven@midlink.org>2009-04-21 16:26:45 +0000
commita2b916ab736802050b19562b7c163e3f3bb1566f (patch)
treed35b68f7bcac43f66f4cdb915ef327b76856594b /libs/nixio/src/tls-socket.c
parent085a0a9ec040fc3ea5ee537d2cee724aa775747b (diff)
Merge nixio 0.2
Diffstat (limited to 'libs/nixio/src/tls-socket.c')
-rw-r--r--libs/nixio/src/tls-socket.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/libs/nixio/src/tls-socket.c b/libs/nixio/src/tls-socket.c
index 0f504ccbb..fe4cb6075 100644
--- a/libs/nixio/src/tls-socket.c
+++ b/libs/nixio/src/tls-socket.c
@@ -1,4 +1,4 @@
-/*
+ /*
* nixio - Linux I/O library for lua
*
* Copyright (C) 2009 Steven Barth <steven@midlink.org>
@@ -65,7 +65,7 @@ static SSL* nixio__checktlssock(lua_State *L) {
static int nixio_tls_sock_recv(lua_State *L) {
SSL *sock = nixio__checktlssock(L);
nixio_tls__check_connected(L);
- int req = luaL_checkinteger(L, 2);
+ uint req = luaL_checkinteger(L, 2);
luaL_argcheck(L, req >= 0, 2, "out of range");
@@ -172,6 +172,24 @@ static int nixio_tls_sock_send(lua_State *L) {
size_t len;
ssize_t sent;
const char *data = luaL_checklstring(L, 2, &len);
+
+ if (lua_gettop(L) > 2) {
+ int offset = luaL_optint(L, 3, 0);
+ if (offset) {
+ if (offset < len) {
+ data += offset;
+ len -= offset;
+ } else {
+ len = 0;
+ }
+ }
+
+ unsigned int wlen = luaL_optint(L, 4, len);
+ if (wlen < len) {
+ len = wlen;
+ }
+ }
+
sent = SSL_write(sock, data, len);
if (sent > 0) {
lua_pushinteger(L, sent);