diff options
Diffstat (limited to 'src/unix.c')
-rw-r--r-- | src/unix.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -69,6 +69,8 @@ static t_opt optset[] = { | |||
69 | }; | 69 | }; |
70 | 70 | ||
71 | /* our socket creation function */ | 71 | /* our socket creation function */ |
72 | /* this is an ad-hoc module that returns a single function | ||
73 | * as such, do not include other functions in this array. */ | ||
72 | static luaL_Reg func[] = { | 74 | static luaL_Reg func[] = { |
73 | {"unix", global_create}, | 75 | {"unix", global_create}, |
74 | {NULL, NULL} | 76 | {NULL, NULL} |
@@ -87,11 +89,14 @@ int luaopen_socket_unix(lua_State *L) { | |||
87 | auxiliar_add2group(L, "unix{master}", "unix{any}"); | 89 | auxiliar_add2group(L, "unix{master}", "unix{any}"); |
88 | auxiliar_add2group(L, "unix{client}", "unix{any}"); | 90 | auxiliar_add2group(L, "unix{client}", "unix{any}"); |
89 | auxiliar_add2group(L, "unix{server}", "unix{any}"); | 91 | auxiliar_add2group(L, "unix{server}", "unix{any}"); |
90 | /* make sure the function ends up in the package table */ | 92 | #if LUA_VERSION_NUM > 501 && !defined(LUA_COMPAT_MODULE) |
93 | lua_pushcfunction(L, global_create); | ||
94 | #else | ||
95 | /* set function into socket namespace */ | ||
91 | luaL_openlib(L, "socket", func, 0); | 96 | luaL_openlib(L, "socket", func, 0); |
97 | lua_pushcfunction(L, global_create); | ||
98 | #endif | ||
92 | /* return the function instead of the 'socket' table */ | 99 | /* return the function instead of the 'socket' table */ |
93 | lua_pushstring(L, "unix"); | ||
94 | lua_gettable(L, -2); | ||
95 | return 1; | 100 | return 1; |
96 | } | 101 | } |
97 | 102 | ||