Esempio n. 1
0
File: udp.c Progetto: leonlee/tome
/*-------------------------------------------------------------------------*\
* Initializes module
\*-------------------------------------------------------------------------*/
int udp_open(lua_State *L)
{
    /* create classes */
    auxiliar_newclass(L, "udp{connected}", udp);
    auxiliar_newclass(L, "udp{unconnected}", udp);
    /* create class groups */
    auxiliar_add2group(L, "udp{connected}",   "udp{any}");
    auxiliar_add2group(L, "udp{unconnected}", "udp{any}");
    auxiliar_add2group(L, "udp{connected}",   "select{able}");
    auxiliar_add2group(L, "udp{unconnected}", "select{able}");
    /* define library functions */
    luaL_openlib(L, NULL, func, 0); 
    return 0;
}
Esempio n. 2
0
/*-------------------------------------------------------------------------*\
* Initializes module
\*-------------------------------------------------------------------------*/
int tcp_open(lua_State *L)
{
    /* create classes */
    auxiliar_newclass(L, "tcp{master}", tcp);
    auxiliar_newclass(L, "tcp{client}", tcp);
    auxiliar_newclass(L, "tcp{server}", tcp);
    /* create class groups */
    auxiliar_add2group(L, "tcp{master}", "tcp{any}");
    auxiliar_add2group(L, "tcp{client}", "tcp{any}");
    auxiliar_add2group(L, "tcp{server}", "tcp{any}");
    /* define library functions */
    luaL_openlib(L, NULL, func, 0); 
    return 0;
}
Esempio n. 3
0
File: unix.c Progetto: leonlee/tome
/*-------------------------------------------------------------------------*\
* Initializes module
\*-------------------------------------------------------------------------*/
int luaopen_socket_unix(lua_State *L) {
    /* create classes */
    auxiliar_newclass(L, "unix{master}", un);
    auxiliar_newclass(L, "unix{client}", un);
    auxiliar_newclass(L, "unix{server}", un);
    /* create class groups */
    auxiliar_add2group(L, "unix{master}", "unix{any}");
    auxiliar_add2group(L, "unix{client}", "unix{any}");
    auxiliar_add2group(L, "unix{server}", "unix{any}");
    /* make sure the function ends up in the package table */
    luaL_openlib(L, "socket", func, 0);
    /* return the function instead of the 'socket' table */
    lua_pushstring(L, "unix");
    lua_gettable(L, -2);
    return 1;
}
Esempio n. 4
0
/*-------------------------------------------------------------------------*\
* Initializes module
\*-------------------------------------------------------------------------*/
int udp_open(lua_State *L) {
    /* create classes */
    auxiliar_newclass(L, "udp{connected}", udp_methods);
    auxiliar_newclass(L, "udp{unconnected}", udp_methods);
    /* create class groups */
    auxiliar_add2group(L, "udp{connected}",   "udp{any}");
    auxiliar_add2group(L, "udp{unconnected}", "udp{any}");
    auxiliar_add2group(L, "udp{connected}",   "select{able}");
    auxiliar_add2group(L, "udp{unconnected}", "select{able}");
    /* define library functions */
    luaL_setfuncs(L, func, 0);
    /* export default UDP size */
    lua_pushliteral(L, "_DATAGRAMSIZE");
    lua_pushinteger(L, UDP_DATAGRAMSIZE);
    lua_rawset(L, -3);
    return 0;
}
Esempio n. 5
0
/*-------------------------------------------------------------------------*\
* Initializes module
\*-------------------------------------------------------------------------*/
int udp_open(lua_State *L)
{
    /* create classes */
    auxiliar_newclass(L, "udp{connected}", udp_methods);
    auxiliar_newclass(L, "udp{unconnected}", udp_methods);
    /* create class groups */
    auxiliar_add2group(L, "udp{connected}",   "udp{any}");
    auxiliar_add2group(L, "udp{unconnected}", "udp{any}");
    auxiliar_add2group(L, "udp{connected}",   "select{able}");
    auxiliar_add2group(L, "udp{unconnected}", "select{able}");
    /* define library functions */
#if LUA_VERSION_NUM > 501 && !defined(LUA_COMPAT_MODULE)
    luaL_setfuncs(L, func, 0);
#else
    luaL_openlib(L, NULL, func, 0);
#endif
    return 0;
}
Esempio n. 6
0
/*-------------------------------------------------------------------------*\
* Initializes module
\*-------------------------------------------------------------------------*/
int luaopen_socket_unix(lua_State *L) {
    /* create classes */
    auxiliar_newclass(L, "unix{master}", un);
    auxiliar_newclass(L, "unix{client}", un);
    auxiliar_newclass(L, "unix{server}", un);
    /* create class groups */
    auxiliar_add2group(L, "unix{master}", "unix{any}");
    auxiliar_add2group(L, "unix{client}", "unix{any}");
    auxiliar_add2group(L, "unix{server}", "unix{any}");
    /* make sure the function ends up in the package table */
    lua_pushcfunction(L, global_create);

    luax_c_insistglobal(L, "socket");
    lua_pushstring(L, "unix");
    lua_pushvalue(L, -3);
    lua_settable(L, -3);

    /* return the function instead of the 'socket' table */
    return 1;
}
Esempio n. 7
0
/*-------------------------------------------------------------------------*\
* Initializes module
\*-------------------------------------------------------------------------*/
LUASOCKET_API int luaopen_socket_serial(lua_State *L) {
    /* create classes */
    auxiliar_newclass(L, "serial{client}", serial_methods);
    /* create class groups */
    auxiliar_add2group(L, "serial{client}", "serial{any}");
#if LUA_VERSION_NUM > 501 && !defined(LUA_COMPAT_MODULE)
    lua_pushcfunction(L, global_create);
    (void) func;
#else
    /* set function into socket namespace */
    luaL_openlib(L, "socket", func, 0);
    lua_pushcfunction(L, global_create);
#endif
    return 1;
}