diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2009-08-24 01:15:00 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2009-08-24 01:15:00 +0200 |
commit | 2ecd826602bd7a83aac609fbc65c32544062f426 (patch) | |
tree | ff01e6bc09659d85876c431de5e3cd7279532ae8 | |
parent | c1af999ee417b7e80a828f9f7d1b39915814595a (diff) |
Export words to XML.
-rw-r--r-- | export_xml.c | 17 | ||||
-rw-r--r-- | word.h | 2 |
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(); @@ -14,4 +14,6 @@ void word_init(); struct word_t *word_get(char *name); void word_free(); +extern struct word_t *words; + #endif |