From 27ece5603fc0cde89183ceb61f915fa64fef1061 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Wed, 29 Jul 2020 12:18:10 -0400 Subject: Added recv_any() recv_any() is a function that takes multiple sockets and waits for one or more of them to receive. See the unit test for examples. --- src/lua-nng-common.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/lua-nng-common.c (limited to 'src/lua-nng-common.c') diff --git a/src/lua-nng-common.c b/src/lua-nng-common.c new file mode 100644 index 0000000..a12ed79 --- /dev/null +++ b/src/lua-nng-common.c @@ -0,0 +1,22 @@ +#include "lua-nng-common.h" +/*Just copy+paste lua's runtime traceback funtion*/ +int traceback (lua_State *L) { + if (!lua_isstring(L, 1)) /* 'message' not a string? */ + return 1; /* keep it intact */ + lua_getglobal(L,"debug"); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + return 1; + } + lua_getfield(L, -1, "traceback"); + if (!lua_isfunction(L, -1)) { + lua_pop(L, 2); + return 1; + } + lua_pushvalue(L, 1); /* pass error message */ + lua_pushinteger(L, 2); /* skip this function and traceback */ + lua_call(L, 2, 1); /* call debug.traceback */ + printf("%s\n",lua_tostring(L,-1)); + return 1; +} + -- cgit v1.2.3-70-g09d2