summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-09-11 19:11:42 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-09-11 19:11:47 +0200
commit1493d9998bb526e6f13bd5de37ec4f790b3592b8 (patch)
tree900c7812f39484c7e5e4cc05100b35c47a98a1c8
parent36f77e74fb6dcb0ac17b327cd1ca09467005ebf0 (diff)
downloadxK-1493d9998bb526e6f13bd5de37ec4f790b3592b8.tar.gz
xK-1493d9998bb526e6f13bd5de37ec4f790b3592b8.tar.xz
xK-1493d9998bb526e6f13bd5de37ec4f790b3592b8.zip
xC: clean up
-rw-r--r--xC.c25
1 files 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;
}