summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--export_xml.c17
-rw-r--r--word.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/export_xml.c b/export_xml.c
index f66381e..ffdeffc 100644
--- a/export_xml.c
+++ b/export_xml.c
@@ -2,6 +2,7 @@
#include <libxml/xmlsave.h>
#include "export_xml.h"
+#include "word.h"
#if !defined(LIBXML_TREE_ENABLED)
#error "libxml must be compiled with tree support"
@@ -54,6 +55,22 @@ int export_xml(struct channel_t *channel, struct user_t *users) {
}
}
+ /* Add words. */
+ xmlNodePtr words_node = xmlNewChild(root_node, NULL, "words", NULL);
+ for(int w = 0; w < WORDS_MAX; w++) {
+ struct word_t *word = &words[w];
+ while(word && word->name) {
+ char s[0xf];
+ xmlNodePtr word_node = xmlNewChild(words_node, NULL, "word", NULL);
+
+ xmlNewChild(word_node, NULL, "name", word->name);
+ sprintf(s, "%d", word->count);
+ xmlNewChild(word_node, NULL, "count", s);
+
+ word = word->next;
+ }
+ }
+
xmlSaveCtxtPtr save_context = xmlSaveToFilename(channel->xmlpath, "UTF-8", 0);
if(!save_context) {
xmlErrorPtr error = xmlGetLastError();
diff --git a/word.h b/word.h
index b0c5d15..1b0f579 100644
--- a/word.h
+++ b/word.h
@@ -14,4 +14,6 @@ void word_init();
struct word_t *word_get(char *name);
void word_free();
+extern struct word_t *words;
+
#endif