From a2cca6c09f4661e86ec27d6e9525eb1e02a973e9 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Mon, 23 Aug 2010 22:19:11 +0200 Subject: Added an exit command. --- commands.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/commands.c b/commands.c index faf12cc..26a7ae5 100644 --- a/commands.c +++ b/commands.c @@ -103,6 +103,11 @@ static void commands_ping(GSocketConnection *connection, const gchar *cmd) { } } +static void commands_exit(GSocketConnection *connection, const gchar *cmd) { + GSocket *socket = g_socket_connection_get_socket(connection); + g_socket_close(socket, NULL); +} + void commands_handle(GSocketConnection *connection, const gchar *cmd) { g_debug(cmd); if(g_strncasecmp(cmd, "ping", 4) == 0) { @@ -111,6 +116,8 @@ void commands_handle(GSocketConnection *connection, const gchar *cmd) { commands_list(connection, cmd); } else if(g_strncasecmp(cmd, "find", 4) == 0) { commands_find(connection, cmd); + } else if(g_strncasecmp(cmd, "exit", 4) == 0) { + commands_exit(connection, cmd); } else { g_debug("unknown command"); gchar *buf = g_strdup_printf("error: unknown command %s\n", cmd); -- cgit v1.2.3