/* * Core function to go to idle state. */ static int ifcore_idle(lua_State *lua) { int r; char *event; event = NULL; if (lua_gettop(lua) != 1) luaL_error(lua, "wrong number of arguments"); luaL_checktype(lua, 1, LUA_TLIGHTUSERDATA); if (get_option_boolean("reenter")) while ((r = request_idle((session *)(lua_topointer(lua, 1)), &event)) == STATUS_NONE); else r = request_idle((session *)(lua_topointer(lua, 1)), &event); lua_pop(lua, 1); if (r == -1) return 0; lua_pushboolean(lua, (r == STATUS_OK)); if (!event) return 1; lua_pushstring(lua, event); xfree(event); return 2; }
/* * Core function to go to idle state. */ static int ifcore_idle(lua_State *lua) { const char *s, *u, *p; int r; if (lua_gettop(lua) != 1) luaL_error(lua, "wrong number of arguments"); luaL_checktype(lua, 1, LUA_TTABLE); if (!(s = get_table_string("server"))) luaL_error(lua, "no mail server specified"); if (!(u = get_table_string("username"))) luaL_error(lua, "no username specified"); p = DISCOVER_PORT(get_table_string("port"), get_table_string("ssl")); r = request_idle(s, p, u); lua_pop(lua, 1); lua_pushboolean(lua, (r == STATUS_RESPONSE_OK)); return 1; }