summaryrefslogtreecommitdiff
path: root/user.c
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-11-09 18:56:23 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2010-11-09 18:56:23 +0100
commitfeca811e0e0afcd67e9153522d40ae58bb468b2f (patch)
treeaf4ba172ff8877e6e9f0dfb44285afffd84ffdfd /user.c
parent91e5543757dad266f041f46d11bf973966368a30 (diff)
Modified time branch to store only first and last time seen.
Diffstat (limited to 'user.c')
-rw-r--r--user.c51
1 files changed, 1 insertions, 50 deletions
diff --git a/user.c b/user.c
index d6554b9..d6171a5 100644
--- a/user.c
+++ b/user.c
@@ -7,8 +7,6 @@
struct user_t *users;
-struct user_time_t *users_time;
-
void user_init() {
users = malloc(sizeof(struct user_t) * USERS_MAX);
memset(users, 0, sizeof(struct user_t) * USERS_MAX);
@@ -35,7 +33,7 @@ struct user_t *user_get(char *nick) {
user->nick = strdup(nick);
memset(user->lines, 0, 24*4 * sizeof(unsigned long));
user->words = user->characters = user->kicks = user->kicked = user->monolog_lines = user->monologs = 0;
- user->seen_first = user->seen_last = user->last_join = user->time_total = 0;
+ user->seen_first = user->seen_last = 0;
user->next = NULL;
char *_nick = nick_get(nick);
user->real_user = strcmp(nick, _nick) ? user_get(_nick) : NULL;
@@ -59,50 +57,3 @@ void user_free() {
}
free(users);
}
-
-void user_time_init() {
- users_time = malloc(sizeof(struct user_time_t) * USERS_MAX);
- memset(users_time, 0, sizeof(struct user_time_t) * USERS_MAX);
-}
-
-struct user_time_t *user_time_get(char *nick, int ignore_real) {
- unsigned long hash = sdbm(nick);
- int index = hash % USERS_MAX;
-
- struct user_time_t *user = &users_time[index];
- /* If hash doesn't match and there exists another user, fetch it. */
- while(user->hash != hash && user->next) user = user->next;
- /* If hash still doesn't match and the user exists, add a new user. */
- if(user->hash != hash && user->nick) {
- struct user_time_t *temp_user = malloc(sizeof(struct user_time_t));
- user->next = temp_user;
- user = temp_user;
- /* Initialize nick to NULL so the user can be correctly added. */
- user->nick = NULL;
- }
- /* Add the new user data to the current pointer if none was found. */
- if(!user->nick) {
- user->hash = hash;
- user->nick = strdup(nick);
- user->seen_first = user->seen_last = user->last_join = user->time_total = 0;
- user->real_user = user->next = NULL;
- }
-
- return (!ignore_real && user->real_user ? user->real_user : user);
-}
-
-void user_time_free() {
- struct user_time_t *user;
- for(int i = 0; i < USERS_MAX; i++) {
- if(users_time[i].nick)
- free(users_time[i].nick);
- user = users_time[i].next;
- while(user) {
- struct user_time_t *temp = user->next;
- free(user->nick);
- free(user);
- user = temp;
- }
- }
- free(users_time);
-}