diff --git a/src/configfiles.c b/src/configfiles.c
index 94a7c78..4c81259 100644
--- a/src/configfiles.c
+++ b/src/configfiles.c
@@ -1,8 +1,22 @@
+/* wXMPPd - (Trying to be) full featured XMPP daemon
+ * Copyright (C) 2011 Gergely Polonkai
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
#include
-#if (HAVE_MMAP == 1)
-# include
-# include
-#endif
+#include
#include
#include
@@ -50,7 +64,10 @@ wxmppd_processConfigfile(const char *file, int startup, wxmppd_config_t **config
return WXMPPD_CONFIG_BADFILE;
}
- wxmppd_loadModule(xpathObject->nodesetval->nodeTab[i]->children->content, (config == NULL));
+ if (config)
+ {
+ (*config)->modules_to_load = g_slist_append((*config)->modules_to_load, g_strdup(xpathObject->nodesetval->nodeTab[i]->children->content));
+ }
}
}
@@ -94,3 +111,57 @@ wxmppd_processConfigfile(const char *file, int startup, wxmppd_config_t **config
return WXMPPD_CONFIG_SUCCESS;
}
+wxmppd_config_t *
+wxmppd_copyConfig(wxmppd_config_t *src)
+{
+ wxmppd_config_t *temp;
+
+ temp = g_new0(wxmppd_config_t, 1);
+
+ if (src->modules_dir != NULL)
+ {
+ temp->modules_dir = g_strdup(src->modules_dir);
+ }
+
+ if (src->modules_to_load)
+ {
+ guint i;
+
+ temp->modules_to_load = NULL;
+
+ for (i = 0; i < g_slist_length(src->modules_to_load); i++)
+ {
+ temp->modules_to_load = g_slist_append(temp->modules_to_load, g_strdup(g_slist_nth(src->modules_to_load, i)->data));
+ }
+ }
+
+ return temp;
+}
+
+static void
+free_slist_data_cb(gpointer data, gpointer user_data)
+{
+ g_free(data);
+}
+
+void
+wxmppd_freeConfig(wxmppd_config_t **config)
+{
+ if (*config)
+ {
+ if ((*config)->modules_dir)
+ {
+ g_free((*config)->modules_dir);
+ }
+ if ((*config)->modules_to_load)
+ {
+ g_slist_foreach((*config)->modules_to_load, free_slist_data_cb, NULL);
+ g_slist_free((*config)->modules_to_load);
+ }
+
+ g_free(*config);
+ }
+
+ *config = NULL;
+}
+
diff --git a/src/configfiles.h b/src/configfiles.h
index 819faa8..5be7000 100644
--- a/src/configfiles.h
+++ b/src/configfiles.h
@@ -1,6 +1,25 @@
+/* wXMPPd - (Trying to be) full featured XMPP daemon
+ * Copyright (C) 2011 Gergely Polonkai
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
#ifndef __WXMPPD_CONFIGFILES_H
# define __WXMPPD_CONFIGFILES_H
+#include
+
enum {
WXMPPD_CONFIG_SUCCESS = 0,
WXMPPD_CONFIG_BADFILE,
@@ -8,9 +27,12 @@ enum {
typedef struct _wxmppd_config_t {
char *modules_dir;
+ GSList *modules_to_load;
} wxmppd_config_t;
int wxmppd_processConfigfile(const char *file, int startup, wxmppd_config_t **config);
+wxmppd_config_t *wxmppd_copyConfig(wxmppd_config_t *src);
+void wxmppd_freeConfig(wxmppd_config_t **config);
#endif /* __WXMPPD_CONFIGFILES_H */