diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-20 21:04:02 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-20 21:04:02 +0200 |
commit | 06e7eb858bffbaf85e91d41825834b38dd0837be (patch) | |
tree | 21cf3a0782d89108d813fb20bf4a5d12f7ebda48 | |
parent | f3c887f589b17bea91467ed69b4f5c11521c5d66 (diff) |
Implemented basic functionality to add to and clear server list.
-rw-r--r-- | servers.c | 28 | ||||
-rw-r--r-- | servers.h | 14 |
2 files changed, 42 insertions, 0 deletions
diff --git a/servers.c b/servers.c new file mode 100644 index 0000000..2efd6d4 --- /dev/null +++ b/servers.c @@ -0,0 +1,28 @@ +#include "servers.h" + +static GSList *servers = NULL; + +gboolean server_add(const gchar *host, const guint16 port) { + struct server *server = g_new0(struct server, 1); + + if(server == NULL) { + g_warning("server_add: g_new0 returned NULL"); + return FALSE; + } + + server->host = g_strdup(host); + server->port = port; + + servers = g_slist_prepend(servers, server); + + return TRUE; +} + +void server_clear() { + for(GSList *node = servers; node; node = g_slist_next(node)) { + struct server *s = node->data; + g_free(s->host); + } + g_slist_free(servers); + servers = NULL; +} diff --git a/servers.h b/servers.h new file mode 100644 index 0000000..2f23090 --- /dev/null +++ b/servers.h @@ -0,0 +1,14 @@ +#ifndef SERVERS_H +#define SERVERS_H + +#include <glib.h> + +struct server { + gchar *host; + guint16 port; +}; + +gboolean server_add(const gchar *host, const guint16 port); +void server_clear(); + +#endif |