-------------------------------------------------------------------------*\ * Setup basic stuff. \*-------------------------------------------------------------------------*/
| 72 | * Setup basic stuff. |
| 73 | \*-------------------------------------------------------------------------*/ |
| 74 | static int base_open(lua_State *L) { |
| 75 | if (socket_open()) { |
| 76 | /* export functions (and leave namespace table on top of stack) */ |
| 77 | lua_newtable(L); |
| 78 | luaL_setfuncs(L, func, 0); |
| 79 | #ifdef LUASOCKET_DEBUG |
| 80 | lua_pushstring(L, "_DEBUG"); |
| 81 | lua_pushboolean(L, 1); |
| 82 | lua_rawset(L, -3); |
| 83 | #endif |
| 84 | /* make version string available to scripts */ |
| 85 | lua_pushstring(L, "_VERSION"); |
| 86 | lua_pushstring(L, LUASOCKET_VERSION); |
| 87 | lua_rawset(L, -3); |
| 88 | return 1; |
| 89 | } else { |
| 90 | lua_pushstring(L, "unable to initialize library"); |
| 91 | lua_error(L); |
| 92 | return 0; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | /*-------------------------------------------------------------------------*\ |
| 97 | * Initializes all library modules. |
no test coverage detected