Exemple #1
0
LUAMOD_API int luaopen_network (lua_State *L)
{
	/* create sentinel */
	loski_NetDriver *drv = (loski_NetDriver *)luaL_newsentinel(L, sizeof(loski_NetDriver), net_sentinel);
	/* initialize library */
	if (loski_opennetwork(drv) != 0) {
		luaL_cancelsentinel(L);
		return luaL_error(L, "unable to initialize library");
	}
	/* create abstract base socket class */
	lua_pushvalue(L, -1);  /* push sentinel */
	luaL_newclass(L, loski_SocketClasses[LOSKI_BASESOCKET], NULL, sck, 1);
	lua_pop(L, 1);  /* remove new class */
	/* create TCP listening socket class */
	lua_pushvalue(L, -1);  /* push sentinel */
	luaL_newclass(L, loski_SocketClasses[LOSKI_LSTNSOCKET],
	                 loski_SocketClasses[LOSKI_BASESOCKET], lst, 1);
	lua_pop(L, 1);  /* remove new class */
	/* create streaming socket class */
	lua_pushvalue(L, -1);  /* push sentinel */
	luaL_newclass(L, loski_SocketClasses[LOSKI_STRMSOCKET],
	                 loski_SocketClasses[LOSKI_BASESOCKET], str, 1);
	lua_pop(L, 1);  /* remove new class */
	/* create TCP connection socket class */
	lua_pushvalue(L, -1);  /* push sentinel */
	luaL_newclass(L, loski_SocketClasses[LOSKI_CONNSOCKET],
	                 loski_SocketClasses[LOSKI_STRMSOCKET], cnt, 1);
	lua_pop(L, 1);  /* remove new class */
	/* create UDP socket class */
	lua_pushvalue(L, -1);  /* push sentinel */
	luaL_newclass(L, loski_SocketClasses[LOSKI_DGRMSOCKET],
	                 loski_SocketClasses[LOSKI_STRMSOCKET], dgm, 1);
	lua_pop(L, 1);  /* remove new class */
	/* create library table */
	luaL_newlibtable(L, lib);
	lua_pushvalue(L, -2);  /* push sentinel */
	luaL_setfuncs(L, lib, 1);
	return 1;
}
Exemple #2
0
LUAMOD_API int luaopen_process(lua_State *L)
{
	/* create sentinel */
	luaL_newsentinel(L, lp_sentinel);
	/* create process class */
	lua_pushvalue(L, -1);  /* push sentinel */
	luaL_newclass(L, LOSKI_PROCESSCLS, cls, 1);
	lua_pop(L, 1);  /* remove new class */
	/* create library table */
	luaL_newlibtable(L, lib);
	lua_pushvalue(L, -2);  /* push sentinel */
	luaL_setfuncs(L, lib, 1);
	/* initialize library */
	if (loski_openprocesses() != 0) {
		luaL_cancelsentinel(L);
		return luaL_error(L, "unable to initialize library");
	}
	return 1;
}
Exemple #3
0
LUA_API int luaopen_mbedtls_entropy_core(lua_State * const L) {

	luaL_newclass(L, CLASS_NAME, methods);

	luaL_newlib(L, funcs);
	BIND_CONSTANT(MBEDTLS_ERR_ENTROPY_SOURCE_FAILED);
	BIND_CONSTANT(MBEDTLS_ERR_ENTROPY_MAX_SOURCES);
	BIND_CONSTANT(MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED);
	BIND_CONSTANT(MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE);
	BIND_CONSTANT(MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR);
	BIND_CONSTANT(MBEDTLS_ENTROPY_MAX_SOURCES);
	BIND_CONSTANT(MBEDTLS_ENTROPY_BLOCK_SIZE);
	BIND_CONSTANT(MBEDTLS_ENTROPY_MAX_SEED_SIZE);
	BIND_CONSTANT(MBEDTLS_ENTROPY_SOURCE_MANUAL);
	BIND_CONSTANT(MBEDTLS_ENTROPY_MAX_SOURCES);
	BIND_CONSTANT(MBEDTLS_ENTROPY_SOURCE_STRONG);
	BIND_CONSTANT(MBEDTLS_ENTROPY_SOURCE_WEAK);
	return 1;
}