diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-01-08 02:52:44 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-01-08 02:52:44 +0100 |
commit | e3ecfb708fa6f868fd15a34ac74cad17082c9e7a (patch) | |
tree | 02af333ef9253d1798fa0ded145b430d8ac42f30 /parsing.c | |
parent | 3f0b80bb129aedd41ee09dccf45c532caf28a854 (diff) |
Implemented monolog counters.
Diffstat (limited to 'parsing.c')
-rw-r--r-- | parsing.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -9,6 +9,7 @@ #include "user.h" #include "word.h" #include "export_xml.h" +#include "config.h" #define NICK_BUFFER_SIZE 0x100 #define TEXT_BUFFER_SIZE 0x400 @@ -19,6 +20,9 @@ pthread_mutex_t user_mutex, word_mutex; static void process_file(FILE *f, struct channel_t *channel, struct regexset_t *rs) { char line[LINE_BUFFER_SIZE]; + struct user_t *last_user = NULL; + int in_monolog = 0, monolog_len = 0;; + while(fgets(line, LINE_BUFFER_SIZE, f)) { int rc; int ovector[30]; @@ -32,6 +36,21 @@ static void process_file(FILE *f, struct channel_t *channel, struct regexset_t * pcre_copy_named_substring(rs->text, line, ovector, rc, "minute", min_s, TIME_BUFFER_SIZE); pthread_mutex_lock(&user_mutex); struct user_t *user = user_get(nick); + if(user == last_user) { + monolog_len++; + if(!in_monolog && monolog_len >= ircstats_config.monolog_min) { + in_monolog = 1; + user->monologs++; + /* Count first lines. */ + user->monolog_lines += monolog_len; + } else if(in_monolog) { + user->monolog_lines++; + } + } else { + last_user = user; + in_monolog = 0; + monolog_len = 1; + } pthread_mutex_unlock(&user_mutex); /* Calculate array index for lines. */ |