diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -6,6 +6,7 @@ #include "regexset.h" #include "channel.h" #include "user.h" +#include "word.h" #define NICK_BUFFER_SIZE 0x100 #define TEXT_BUFFER_SIZE 0x400 @@ -22,10 +23,11 @@ int main(int argc, char **argv) { channel_free(); return 1; } - user_init(); /* Parsing stuff goes here. */ for(int chan_i = 0; chan_i < channel_get_count(); chan_i++) { + user_init(); + word_init(); struct channel_t *channel = channel_get(chan_i); printf("Channel %s\n", channel->name); struct channel_file_t *file = channel->files; @@ -59,9 +61,12 @@ int main(int argc, char **argv) { int len = 0; for(char *pos = text; pos < end; pos++) { if(isblank(*pos)) { - if(len) + if(len) { user->words++; - word[len] = '\0'; + word[len] = '\0'; + struct word_t *word_s = word_get(word); + word_s->count++; + } len = 0; *word = '\0'; } else if isalpha(*pos) { @@ -71,8 +76,12 @@ int main(int argc, char **argv) { *word = '\0'; } } - if(len) + if(len) { user->words++; + word[len] = '\0'; + struct word_t *word_s = word_get(word); + word_s->count++; + } continue; } @@ -88,9 +97,10 @@ int main(int argc, char **argv) { file = file->next; } + user_free(); + word_free(); } - user_free(); cfg_free(); channel_free(); rs_free(); |