summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2009-08-15 18:07:02 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2009-08-15 18:07:02 +0200
commit3efd96ff79f4f5669c3422a1f592f09176c77121 (patch)
tree0efd426765206625fdbf64e4c9cab4cce83010da /main.c
parent62b45cb26d7868b21ba4b854d2d3b8befeee9327 (diff)
Added a hash table to keep track of words.
Moved the sdbm hash function into sdbm.c. Init and free users and words inside the channel loop. Increased the size of the user hash table to 1000.
Diffstat (limited to 'main.c')
-rw-r--r--main.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/main.c b/main.c
index 300a424..f5b743b 100644
--- a/main.c
+++ b/main.c
@@ -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();