From 1493d9998bb526e6f13bd5de37ec4f790b3592b8 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Sun, 11 Sep 2022 19:11:42 +0200 Subject: xC: clean up --- xC.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/xC.c b/xC.c index c35c158..a378421 100644 --- a/xC.c +++ b/xC.c @@ -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; } -- cgit v1.2.3-70-g09d2