summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--servers.c28
-rw-r--r--servers.h14
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