xC: clean up

This commit is contained in:
Přemysl Eric Janouch 2022-09-11 19:11:42 +02:00
parent 36f77e74fb
commit 1493d9998b
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 16 additions and 9 deletions

25
xC.c
View File

@ -9940,20 +9940,27 @@ lua_server_gc (lua_State *L)
return lua_weak_gc (L, &lua_server_info);
}
static const char *
lua_server_state_to_string (enum server_state state)
{
switch (state)
{
case IRC_DISCONNECTED: return "disconnected";
case IRC_CONNECTING: return "connecting";
case IRC_CONNECTED: return "connected";
case IRC_REGISTERED: return "registered";
case IRC_CLOSING: return "closing";
case IRC_HALF_CLOSED: return "half-closed";
}
return "?";
}
static int
lua_server_get_state (lua_State *L)
{
struct lua_weak *wrapper = lua_weak_deref (L, &lua_server_info);
struct server *server = wrapper->object;
switch (server->state)
{
case IRC_DISCONNECTED: lua_pushstring (L, "disconnected"); break;
case IRC_CONNECTING: lua_pushstring (L, "connecting"); break;
case IRC_CONNECTED: lua_pushstring (L, "connected"); break;
case IRC_REGISTERED: lua_pushstring (L, "registered"); break;
case IRC_CLOSING: lua_pushstring (L, "closing"); break;
case IRC_HALF_CLOSED: lua_pushstring (L, "half_closed"); break;
}
lua_pushstring (L, lua_server_state_to_string (server->state));
return 1;
}