summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}