diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-25 20:40:48 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-25 20:40:48 +0200 |
commit | 3d0656a3ae5c7b18917528200e7c33cef49b966d (patch) | |
tree | 7bd53bf7df3cd8f4a790d1b4294d8a531d574505 | |
parent | 03b8bec204e909f28ddafb282414e5392ba172ed (diff) |
Implemented server_find().
-rw-r--r-- | server_communication.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/server_communication.c b/server_communication.c index 45f4243..007b599 100644 --- a/server_communication.c +++ b/server_communication.c @@ -70,3 +70,29 @@ gboolean server_ping(struct server *server) { return result; } +GSList *server_find(struct server *server, const gchar *type, const gchar *str) { + GSocket *socket = server_connect(server); + + if(socket == NULL) { + return NULL; + } + + gchar buffer[0x400]; + g_snprintf(buffer, 0x400, "find %s %s\nexit\n", type, str); + g_socket_send(socket, buffer, strlen(buffer), NULL, NULL); + + GSList *list = NULL; + gssize size; + while((size = g_socket_receive(socket, buffer, 0x400, NULL, NULL)) > 0) { + if(buffer[size - 1] == '\n') { + buffer[size - 1] = '\0'; + } + g_debug("got %s", buffer); + } + + g_debug("closed: %d", size); + + g_socket_close(socket, NULL); + + return NULL; +} |