diff options
Diffstat (limited to 'server_communication.c')
-rw-r--r-- | server_communication.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/server_communication.c b/server_communication.c index 007b599..f331a35 100644 --- a/server_communication.c +++ b/server_communication.c @@ -1,4 +1,5 @@ #include "server_communication.h" +#include "music.h" #include <gio/gio.h> #include <string.h> @@ -70,7 +71,7 @@ gboolean server_ping(struct server *server) { return result; } -GSList *server_find(struct server *server, const gchar *type, const gchar *str) { +gchar **server_find(struct server *server, const gchar *type, const gchar *str) { GSocket *socket = server_connect(server); if(socket == NULL) { @@ -81,18 +82,16 @@ GSList *server_find(struct server *server, const gchar *type, const gchar *str) 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; + GString *string = g_string_new(NULL); 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_string_append_len(string, buffer, size); } - g_debug("closed: %d", size); - g_socket_close(socket, NULL); - return NULL; + gchar **data = g_strsplit(string->str, "\n", 0); + g_string_free(string, TRUE); + + return data; } |