summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-09-03 21:25:07 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2010-09-03 21:25:07 +0200
commit2f25352bd65ae7acb4612bcbc293a0f74239b67c (patch)
tree9a8c65e85b168c5c2717cf124bbff46d94efeb56
parentfd880c0afd2a369738d697bf621d35e473c3ea70 (diff)
Added 'name' to the server struct.
-rw-r--r--servers.c14
-rw-r--r--servers.h5
2 files changed, 13 insertions, 6 deletions
diff --git a/servers.c b/servers.c
index 2101395..6afce35 100644
--- a/servers.c
+++ b/servers.c
@@ -5,8 +5,8 @@
GSList *servers = NULL;
-gboolean server_add(const gchar *host, const guint16 http_port,
- const guint16 command_port) {
+gboolean server_add(const gchar *name, const gchar *host,
+ const guint16 http_port, const guint16 command_port) {
struct server *server = g_new0(struct server, 1);
if(server == NULL) {
@@ -14,6 +14,7 @@ gboolean server_add(const gchar *host, const guint16 http_port,
return FALSE;
}
+ server->name = g_strdup(name);
server->host = g_strdup(host);
server->http_port = http_port;
server->command_port = command_port;
@@ -40,12 +41,17 @@ void servers_init() {
gchar **s = conf_get_string_list("audist", "servers", &length);
for(int i = 0; i < length; i++) {
gchar *section = g_strdup_printf("server/%s", s[i]);
+ gchar *host = conf_get_string(section, "host");
guint16 http_port = conf_get_int(section, "http_port");
guint16 command_port = conf_get_int(section, "command_port");
g_free(section);
- server_add(s[i], http_port, command_port);
- g_debug(" server %d: %s (%d, %d)", i, s[i], http_port, command_port);
+ server_add(s[i], host, http_port, command_port);
+ g_free(host);
+ }
+
+ if(s != NULL) {
+ g_strfreev(s);
}
}
diff --git a/servers.h b/servers.h
index 694e8a2..08f458b 100644
--- a/servers.h
+++ b/servers.h
@@ -4,6 +4,7 @@
#include <glib.h>
struct server {
+ gchar *name;
gchar *host;
guint16 http_port;
guint16 command_port;
@@ -11,8 +12,8 @@ struct server {
extern GSList *servers;
-gboolean server_add(const gchar *host, const guint16 http_port,
- const guint16 command_port);
+gboolean server_add(const gchar *name, const gchar *host,
+ const guint16 http_port, const guint16 command_port);
gboolean server_remove(struct server *server);
void servers_init();
void servers_free();