|
|
@@ -117,13 +117,13 @@ static int opt_linger(HSQUIRRELVM v, p_socket ps)
|
|
|
if(sq_gettype(v, 3) != OT_TABLE) return sq_throwerror(v, _SC("table expected as parameter 2"));
|
|
|
sq_pushliteral(v, _SC("on"));
|
|
|
sq_get(v, 3);
|
|
|
- if (!sq_gettype(v, -1) != OT_BOOL)
|
|
|
+ if (sq_gettype(v, -1) != OT_BOOL)
|
|
|
return sq_throwerror(v, _SC("boolean 'on' field expected"));
|
|
|
SQ_GET_BOOL(v, -1, bval);
|
|
|
li.l_onoff = (u_short) bval == SQTrue;
|
|
|
sq_pushliteral(v, _SC("timeout"));
|
|
|
sq_get(v, 3);
|
|
|
- if (!sq_gettype(v, -1) != OT_INTEGER)
|
|
|
+ if (sq_gettype(v, -1) != OT_INTEGER)
|
|
|
return sq_throwerror(v, _SC("integer 'timeout' field expected"));
|
|
|
SQ_GET_INTEGER(v, -1, ival);
|
|
|
li.l_linger = (u_short) ival;
|
|
|
@@ -181,15 +181,15 @@ static int inet_aton(const char *cp, struct in_addr *inp)
|
|
|
//#define inet_aton inet_addr
|
|
|
//#define inet_aton(a,b) inet_pton(a,b, AF_INET)
|
|
|
#endif
|
|
|
-
|
|
|
+
|
|
|
static SQRESULT socket_open(HSQUIRRELVM v)
|
|
|
-{
|
|
|
+{
|
|
|
lua_socket_open();
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
static SQRESULT socket_close(HSQUIRRELVM v)
|
|
|
-{
|
|
|
+{
|
|
|
lua_socket_close();
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -201,14 +201,14 @@ static int opt_setmembership(HSQUIRRELVM v, p_socket ps, int level, int name)
|
|
|
if(sq_gettype(v, 3) != OT_TABLE) return sq_throwerror(v, _SC("table expected as parameter 2"));
|
|
|
sq_pushliteral(v, _SC("multiaddr"));
|
|
|
sq_get(v, 3);
|
|
|
- if (!sq_gettype(v, -1) != OT_STRING)
|
|
|
+ if (sq_gettype(v, -1) != OT_STRING)
|
|
|
return sq_throwerror(v, _SC("string 'multiaddr' field expected"));
|
|
|
SQ_GET_STRING(v, -1, multiaddr);
|
|
|
if (!inet_aton(multiaddr, &val.imr_multiaddr))
|
|
|
return sq_throwerror(v, _SC("invalid 'multiaddr' ip address"));
|
|
|
sq_pushliteral(v, _SC("interface"));
|
|
|
sq_get(v, 3);
|
|
|
- if (!sq_gettype(v, -1) != OT_STRING)
|
|
|
+ if (sq_gettype(v, -1) != OT_STRING)
|
|
|
return sq_throwerror(v, _SC("string 'interface' field expected"));
|
|
|
val.imr_interface.s_addr = htonl(INADDR_ANY);
|
|
|
SQ_GET_STRING(v, -1, saddr);
|
|
|
@@ -647,7 +647,7 @@ static int buffer_meth_send(HSQUIRRELVM v, p_buffer buf) {
|
|
|
SQ_OPT_INTEGER(v, 3, start, 0);
|
|
|
SQ_OPT_INTEGER(v, 4, end, -1);
|
|
|
#ifdef LUASOCKET_DEBUG
|
|
|
- p_timeout tm =
|
|
|
+ p_timeout tm =
|
|
|
#endif
|
|
|
lua_timeout_markstart(buf->tm);
|
|
|
if (start < 0) start = (data_size+start);
|
|
|
@@ -677,9 +677,9 @@ static int buffer_meth_receive(HSQUIRRELVM v, p_buffer buf) {
|
|
|
SQBlob b(0, 8192);
|
|
|
SQ_OPT_STRING(v, 3, prefix, NULL);
|
|
|
#ifdef LUASOCKET_DEBUG
|
|
|
- p_timeout tm =
|
|
|
+ p_timeout tm =
|
|
|
#endif
|
|
|
- lua_timeout_markstart(buf->tm);
|
|
|
+ lua_timeout_markstart(buf->tm);
|
|
|
/* initialize buffer with optional extra prefix
|
|
|
* (useful for concatenating previous partial results) */
|
|
|
if(prefix) {
|
|
|
@@ -857,17 +857,17 @@ typedef struct t_tcp_ {
|
|
|
typedef t_tcp *p_tcp;
|
|
|
|
|
|
static const SQChar SQ_tcp_TAG[] = _SC("sq_tcp");
|
|
|
-#define GET_tcp_INSTANCE_AT(v, idx) \
|
|
|
- p_tcp tcp; \
|
|
|
+#define GET_tcp_INSTANCE_AT(v, idx) \
|
|
|
+ p_tcp tcp; \
|
|
|
if((_rc_ = sq_getinstanceup(v,idx,(SQUserPointer*)&tcp,(void*)SQ_tcp_TAG)) < 0) return _rc_;
|
|
|
|
|
|
-#define GET_tcp_client_INSTANCE_AT(v, idx) GET_tcp_INSTANCE_AT(v, idx)\
|
|
|
+#define GET_tcp_client_INSTANCE_AT(v, idx) GET_tcp_INSTANCE_AT(v, idx)\
|
|
|
if(tcp->type != TCP_TYPE_CLIENT) return sq_throwerror(v, _SC("tcp client expected"));
|
|
|
|
|
|
-#define GET_tcp_server_INSTANCE_AT(v, idx) GET_tcp_INSTANCE_AT(v, idx)\
|
|
|
+#define GET_tcp_server_INSTANCE_AT(v, idx) GET_tcp_INSTANCE_AT(v, idx)\
|
|
|
if(tcp->type != TCP_TYPE_SERVER) return sq_throwerror(v, _SC("tcp server expected"));
|
|
|
|
|
|
-#define GET_tcp_master_INSTANCE_AT(v, idx) GET_tcp_INSTANCE_AT(v, idx)\
|
|
|
+#define GET_tcp_master_INSTANCE_AT(v, idx) GET_tcp_INSTANCE_AT(v, idx)\
|
|
|
if(tcp->type != TCP_TYPE_MASTER) return sq_throwerror(v, _SC("tcp master expected"));
|
|
|
|
|
|
/*-------------------------------------------------------------------------*\
|
|
|
@@ -1161,14 +1161,14 @@ static t_opt udp_opt[] = {
|
|
|
};
|
|
|
|
|
|
static const SQChar SQ_udp_TAG[] = _SC("sq_udp");
|
|
|
-#define GET_udp_INSTANCE_AT(v, idx) \
|
|
|
- p_udp udp; \
|
|
|
+#define GET_udp_INSTANCE_AT(v, idx) \
|
|
|
+ p_udp udp; \
|
|
|
if((_rc_ = sq_getinstanceup(v,idx,(SQUserPointer*)&udp,(void*)SQ_udp_TAG)) < 0) return _rc_;
|
|
|
|
|
|
-#define GET_udp_connected_INSTANCE_AT(v, idx) GET_udp_INSTANCE_AT(v, idx)\
|
|
|
+#define GET_udp_connected_INSTANCE_AT(v, idx) GET_udp_INSTANCE_AT(v, idx)\
|
|
|
if(udp->type != UDP_TYPE_CONNECTED) return sq_throwerror(v, _SC("udp connected expected"));
|
|
|
|
|
|
-#define GET_udp_unconnected_INSTANCE_AT(v, idx) GET_udp_INSTANCE_AT(v, idx)\
|
|
|
+#define GET_udp_unconnected_INSTANCE_AT(v, idx) GET_udp_INSTANCE_AT(v, idx)\
|
|
|
if(udp->type != UDP_TYPE_UNCONNECTED) return sq_throwerror(v, _SC("udp unconnected expected"));
|
|
|
|
|
|
|
|
|
@@ -1455,17 +1455,17 @@ typedef struct t_unix_ {
|
|
|
typedef t_unix *p_unix;
|
|
|
|
|
|
static const SQChar SQ_unix_TAG[] = _SC("sq_unix_socket");
|
|
|
-#define GET_unix_INSTANCE_AT(v, idx) \
|
|
|
- p_unix unix_sock; \
|
|
|
+#define GET_unix_INSTANCE_AT(v, idx) \
|
|
|
+ p_unix unix_sock; \
|
|
|
if((_rc_ = sq_getinstanceup(v,idx,(SQUserPointer*)&unix_sock,(void*)SQ_unix_TAG)) < 0) return _rc_;
|
|
|
|
|
|
-#define GET_unix_client_INSTANCE_AT(v, idx) GET_unix_INSTANCE_AT(v, idx)\
|
|
|
+#define GET_unix_client_INSTANCE_AT(v, idx) GET_unix_INSTANCE_AT(v, idx)\
|
|
|
if(unix_sock->type != UNIX_TYPE_CLIENT) return sq_throwerror(v, _SC("unix client expected"));
|
|
|
|
|
|
-#define GET_unix_server_INSTANCE_AT(v, idx) GET_unix_INSTANCE_AT(v, idx)\
|
|
|
+#define GET_unix_server_INSTANCE_AT(v, idx) GET_unix_INSTANCE_AT(v, idx)\
|
|
|
if(unix_sock->type != UNIX_TYPE_SERVER) return sq_throwerror(v, _SC("unix server expected"));
|
|
|
|
|
|
-#define GET_unix_master_INSTANCE_AT(v, idx) GET_unix_INSTANCE_AT(v, idx)\
|
|
|
+#define GET_unix_master_INSTANCE_AT(v, idx) GET_unix_INSTANCE_AT(v, idx)\
|
|
|
if(unix_sock->type != UNIX_TYPE_MASTER) return sq_throwerror(v, _SC("unix master expected"));
|
|
|
|
|
|
|
|
|
@@ -1906,7 +1906,7 @@ static void return_fd(HSQUIRRELVM v, fd_set *set, t_socket max_fd,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#define INT_CONST(v,num) sq_pushstring(v,_SC(#num),-1);sq_pushinteger(v,num);sq_newslot(v,-3,SQTrue);
|
|
|
+#define INT_CONST(v,num) sq_pushstring(v,_SC(#num),-1);sq_pushinteger(v,num);sq_newslot(v,-3,SQTrue);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
extern "C" {
|
|
|
@@ -1916,7 +1916,7 @@ extern "C" {
|
|
|
{
|
|
|
sq_pushliteral(v,_SC("socket"));
|
|
|
sq_newtable(v);
|
|
|
-
|
|
|
+
|
|
|
INT_CONST(v, IO_DONE);
|
|
|
INT_CONST(v, IO_TIMEOUT);
|
|
|
INT_CONST(v, IO_CLOSED);
|