Exemple #1
0
static int magnet_status_set(lua_State *L) {
	server *srv = magnet_get_server(L);

	/* __newindex: param 1 is the (empty) table the value is supposed to be set in */
	const_buffer key = magnet_checkconstbuffer(L, 2);
	int counter = (int) luaL_checkinteger(L, 3);

	status_counter_set(srv, key.ptr, key.len, counter);

	return 0;
}
static int magnet_status_set(lua_State *L) {
	size_t key_len = 0;
	server *srv;

	const char *key = luaL_checklstring(L, 2, &key_len);
	int counter = luaL_checkint(L, 3);

	lua_pushstring(L, "lighty.srv");
	lua_gettable(L, LUA_REGISTRYINDEX);
	srv = lua_touserdata(L, -1);
	lua_pop(L, 1);

	status_counter_set(srv, key, key_len, counter);

	return 0;
}