diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2009-09-06 16:53:24 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2009-09-06 16:53:24 +0200 |
commit | 27d37093ab87c2a1b8e846b4f4df83bf19ceba4c (patch) | |
tree | ed11a87c1b50b8f76fb569018ba51d08f068b507 | |
parent | d6c2fcddfdefedb68222e9c4163a765fe56dc8e9 (diff) |
Count the number of total characters per user.
-rw-r--r-- | export_xml.c | 2 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | user.c | 2 | ||||
-rw-r--r-- | user.h | 2 |
4 files changed, 5 insertions, 2 deletions
diff --git a/export_xml.c b/export_xml.c index f38a803..db1d592 100644 --- a/export_xml.c +++ b/export_xml.c @@ -47,6 +47,8 @@ int export_xml(struct channel_t *channel, struct user_t *users) { xmlNewChild(user_node, NULL, "nick", user->nick); snprintf(s, 0xf, "%d", user->words); xmlNewChild(user_node, NULL, "words", s); + snprintf(s, 0xf, "%d", user->characters); + xmlNewChild(user_node, NULL, "characters", s); /* Add lines for this user. */ xmlNodePtr lines_node = xmlNewChild(user_node, NULL, "lines", NULL); @@ -77,6 +77,7 @@ int main(int argc, char **argv) { /* Count words. */ wchar_t wtext[TEXT_BUFFER_SIZE]; mbstowcs(wtext, text, TEXT_BUFFER_SIZE); + user->characters += wcslen(wtext); wchar_t word[TEXT_BUFFER_SIZE]; wchar_t *end = wcschr(wtext, '\0'); *word = '\0'; @@ -33,7 +33,7 @@ struct user_t *user_get(char *_nick) { user->hash = hash; user->nick = strdup(nick); memset(user->lines, 0, 24*4 * sizeof(unsigned long)); - user->words = 0; + user->words = user->characters = 0; user->next = NULL; } @@ -7,7 +7,7 @@ struct user_t { unsigned long hash; char *nick; unsigned long lines[24*4]; - unsigned long long words; + unsigned long long words, characters; struct user_t *next; }; |