aboutsummaryrefslogtreecommitdiff
path: root/src/unix.c
diff options
context:
space:
mode:
authorDiego Nehab <diego@impa.br>2013-05-29 16:56:56 +0800
committerDiego Nehab <diego@impa.br>2013-05-29 16:56:56 +0800
commit79e6c4915d267e149e1f3b134901bf355d439c15 (patch)
treefded0a926a268d88710e652fa8cdf06ec77cf217 /src/unix.c
parent5167ddaf499cf198b10208a2f76c27629e99ae1b (diff)
downloadluasocket-79e6c4915d267e149e1f3b134901bf355d439c15.tar.gz
luasocket-79e6c4915d267e149e1f3b134901bf355d439c15.tar.bz2
luasocket-79e6c4915d267e149e1f3b134901bf355d439c15.zip
Export global only if LUA_COMPAT_MODULE defined.
Diffstat (limited to 'src/unix.c')
-rw-r--r--src/unix.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/unix.c b/src/unix.c
index 73e7b69..5710c27 100644
--- a/src/unix.c
+++ b/src/unix.c
@@ -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. */
72static luaL_Reg func[] = { 74static 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