summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-11-15 18:46:40 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2010-11-15 18:46:40 +0100
commit14e35e4d1f2f8927685b0c55bdc1f5d6bd5a2e9f (patch)
tree87eb0eaff490900144ad00024815f65d7b702d16
parentad044e229af5e523699a977e7c0393d42695586e (diff)
Removed XML export.
-rw-r--r--SConstruct3
-rw-r--r--channel.c4
-rw-r--r--channel.h3
-rw-r--r--config.c10
-rw-r--r--export_xml.c137
-rw-r--r--export_xml.h9
-rw-r--r--main.c1
-rw-r--r--parsing.c2
8 files changed, 5 insertions, 164 deletions
diff --git a/SConstruct b/SConstruct
index cbc8521..97e885a 100644
--- a/SConstruct
+++ b/SConstruct
@@ -3,7 +3,7 @@ AddOption('--release', action = 'store_true')
env = Environment()
conf = Configure(env)
-for lib in ('config', 'pcre', 'xml2'):
+for lib in ('config', 'pcre'):
if not conf.CheckLib(lib):
print 'Could not find %s' % lib
Exit(1)
@@ -18,7 +18,6 @@ else:
env.ParseConfig('pkg-config --cflags --libs libconfig')
env.ParseConfig('pcre-config --cflags --libs')
-env.ParseConfig('xml2-config --cflags --libs')
env.Program('ircstats', Glob('*.c'))
diff --git a/channel.c b/channel.c
index 8c32a96..559f3c6 100644
--- a/channel.c
+++ b/channel.c
@@ -13,7 +13,7 @@ void channel_init() {
channel_count = 0;
}
-struct channel_t *channel_add(const char *name, const char *xmlpath) {
+struct channel_t *channel_add(const char *name) {
channels = realloc(channels, ++channel_count * sizeof(struct channel_t));
if(!channels) {
char *error = strerror(errno);
@@ -22,7 +22,6 @@ struct channel_t *channel_add(const char *name, const char *xmlpath) {
}
struct channel_t *channel = &channels[channel_count-1];
channel->name = strdup(name);
- channel->xmlpath = strdup(xmlpath);
channel->files = NULL;
memset(channel->hours, 0, 24*4 * sizeof(unsigned long));
return channel;
@@ -55,7 +54,6 @@ struct channel_t *channel_get(int index) {
void channel_free() {
for(int i = 0; i < channel_count; i++) {
free(channels[i].name);
- free(channels[i].xmlpath);
struct channel_file_t *file = channels[i].files;
while(file) {
struct channel_file_t *next = file->next;
diff --git a/channel.h b/channel.h
index 3f4e4cd..0335782 100644
--- a/channel.h
+++ b/channel.h
@@ -11,14 +11,13 @@ struct channel_file_t {
struct channel_t {
char *name;
- char *xmlpath;
struct channel_file_t *files;
unsigned long hours[24*4];
};
void channel_init();
-struct channel_t *channel_add(const char *name, const char *xmlpath);
+struct channel_t *channel_add(const char *name);
struct channel_file_t *channel_file_add(struct channel_t *channel, const char *path, int rs_index);
int channel_get_count();
struct channel_t *channel_get(int index);
diff --git a/config.c b/config.c
index 84bcf39..9d465bd 100644
--- a/config.c
+++ b/config.c
@@ -87,21 +87,15 @@ int cfg_init() {
int channel_count = config_setting_length(channels_setting);
for(int i = 0; i < channel_count; i++) {
config_setting_t *channel_setting = config_setting_get_elem(channels_setting, i);
- const char *name, *xmlpath;
+ const char *name;
if(!config_setting_lookup_string(channel_setting, "name", &name)) {
char *sname;
sname = malloc(sizeof(char) * 16);
snprintf(sname, 16, "channel #%d", i+1);
name = sname;
}
- if(!config_setting_lookup_string(channel_setting, "xmlpath", &xmlpath)) {
- /* Index-based filename if xmlpath isn't set. */
- char temp[0xf];
- snprintf(temp, 0xf, "%d.xml", i);
- xmlpath = strdup(temp);
- }
struct channel_t *channel;
- if(!(channel = channel_add(name, xmlpath))) {
+ if(!(channel = channel_add(name))) {
return 0;
}
config_setting_t *files = config_setting_get_member(channel_setting, "files");
diff --git a/export_xml.c b/export_xml.c
deleted file mode 100644
index 91f5af0..0000000
--- a/export_xml.c
+++ /dev/null
@@ -1,137 +0,0 @@
-#include <libxml/xmlwriter.h>
-#include <string.h>
-
-#include "export_xml.h"
-#include "word.h"
-
-#if !defined(LIBXML_WRITER_ENABLED)
-#error "libxml must be compiled with text writer support"
-#endif
-
-
-int export_xml(struct channel_t *channel, struct user_t *users) {
- /* Create document and set root node. */
- xmlTextWriterPtr writer = xmlNewTextWriterFilename(channel->xmlpath, 0);
- if(writer == NULL) {
- fprintf(stderr, "Failed to create text writer for filename \"%s\"\n", channel->xmlpath);
- return 0;
- }
-
- xmlTextWriterStartDocument(writer, "1.0", "UTF-8", NULL);
- xmlTextWriterStartElement(writer, (const xmlChar*)"channel");
-
- /* Set the channel name. */
- xmlTextWriterStartElement(writer, (const xmlChar*)"name");
- xmlTextWriterWriteString(writer, (const xmlChar*)channel->name);
- xmlTextWriterEndElement(writer);
-
- /* Add lines. */
- xmlTextWriterStartElement(writer, (const xmlChar*)"lines");
- for(int h = 0; h < 24; h++) {
- xmlTextWriterStartElement(writer, (const xmlChar*)"hour");
- for(int q = 0; q < 4; q++) {
- xmlTextWriterStartElement(writer, (const xmlChar*)"quarter");
- xmlTextWriterWriteFormatString(writer, "%lu", channel->hours[h*4 + q]);
- xmlTextWriterEndElement(writer);
- }
- xmlTextWriterEndElement(writer); // hour
- }
- xmlTextWriterEndElement(writer); // lines
-
- /* Add users. */
- xmlTextWriterStartElement(writer, (const xmlChar*)"users");
- for(int u = 0; u < USERS_MAX; u++) {
- struct user_t *user = &users[u];
- /* Iterate while we have a user (nick is non-NULL). */
- while(user && user->nick) {
- /* Skip <NULL> (filtered nicks eg. bots). */
- if(strcmp(user->nick, "<NULL>") == 0) {
- user = user->next;
- continue;
- }
- xmlTextWriterStartElement(writer, (const xmlChar*)"user");
-
- xmlTextWriterStartElement(writer, (const xmlChar*)"nick");
- xmlTextWriterWriteString(writer, (const xmlChar*)user->nick);
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterStartElement(writer, (const xmlChar*)"words");
- xmlTextWriterWriteFormatString(writer, "%llu", user->words);
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterStartElement(writer, (const xmlChar*)"characters");
- xmlTextWriterWriteFormatString(writer, "%llu", user->characters);
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterStartElement(writer, (const xmlChar*)"kicks");
- xmlTextWriterWriteFormatString(writer, "%llu", user->kicks);
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterStartElement(writer, (const xmlChar*)"kicked");
- xmlTextWriterWriteFormatString(writer, "%llu", user->kicked);
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterStartElement(writer, (const xmlChar*)"monolog_lines");
- xmlTextWriterWriteFormatString(writer, "%llu", user->monolog_lines);
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterStartElement(writer, (const xmlChar*)"monologs");
- xmlTextWriterWriteFormatString(writer, "%llu", user->monologs);
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterStartElement(writer, (const xmlChar*)"seen_first");
- xmlTextWriterWriteFormatString(writer, "%lu", user->seen_first);
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterStartElement(writer, (const xmlChar*)"seen_last");
- xmlTextWriterWriteFormatString(writer, "%lu", user->seen_last);
- xmlTextWriterEndElement(writer);
-
- /* Add lines for this user. */
- xmlTextWriterStartElement(writer, (const xmlChar*)"lines");
- for(int h = 0; h < 24; h++) {
- xmlTextWriterStartElement(writer, (const xmlChar*)"hour");
- for(int q = 0; q < 4; q++) {
- xmlTextWriterStartElement(writer, (const xmlChar*)"quarter");
- xmlTextWriterWriteFormatString(writer, "%lu", user->lines[h*4 + q]);
- xmlTextWriterEndElement(writer);
- }
- xmlTextWriterEndElement(writer); // hour
- }
- xmlTextWriterEndElement(writer); // lines
- user = user->next;
-
- xmlTextWriterEndElement(writer); // user
- }
- }
- xmlTextWriterEndElement(writer); // users
-
- /* Add words. */
- xmlTextWriterStartElement(writer, (const xmlChar*)"words");
- for(int w = 0; w < WORDS_MAX; w++) {
- struct word_t *word = &words[w];
- while(word && word->name) {
- xmlTextWriterStartElement(writer, (const xmlChar*)"word");
-
- xmlTextWriterStartElement(writer, (const xmlChar*)"name");
- xmlTextWriterWriteString(writer, (const xmlChar*)word->name);
- xmlTextWriterEndElement(writer);
-
- xmlTextWriterStartElement(writer, (const xmlChar*)"count");
- xmlTextWriterWriteFormatString(writer, "%llu", word->count);
- xmlTextWriterEndElement(writer);
-
- word = word->next;
-
- xmlTextWriterEndElement(writer); // word
- }
- }
- xmlTextWriterEndElement(writer); // words
-
- xmlTextWriterEndElement(writer); // channel
-
- xmlTextWriterEndDocument(writer);
- xmlFreeTextWriter(writer);
-
- return 1;
-}
diff --git a/export_xml.h b/export_xml.h
deleted file mode 100644
index f16379a..0000000
--- a/export_xml.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _EXPORT_XML_H_
-#define _EXPORT_XML_H_
-
-#include "channel.h"
-#include "user.h"
-
-int export_xml(struct channel_t *channel, struct user_t *users);
-
-#endif
diff --git a/main.c b/main.c
index b6fb6ca..5c34642 100644
--- a/main.c
+++ b/main.c
@@ -5,7 +5,6 @@
#include "channel.h"
#include "user.h"
#include "word.h"
-#include "export_xml.h"
#include "nick.h"
#include "parsing.h"
diff --git a/parsing.c b/parsing.c
index 2447363..aeec3e6 100644
--- a/parsing.c
+++ b/parsing.c
@@ -8,7 +8,6 @@
#include "channel.h"
#include "user.h"
#include "word.h"
-#include "export_xml.h"
#include "config.h"
#define NICK_BUFFER_SIZE 0x100
@@ -349,7 +348,6 @@ void process() {
file = file->next;
}
- export_xml(channel, users);
user_free();
word_free();
}