Bugfix: memory and thread-deleting problems
[monky] / src / users.c
index 1b97725..5ba7959 100644 (file)
@@ -10,7 +10,7 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
+ * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
  *     (see AUTHORS)
  * All rights reserved.
  *
@@ -93,7 +93,7 @@ static void user_time(char *ptr)
                }
        }
 }
-static void tty_user_time(char *ptr, char *tty, char times_in_seconds)
+static void tty_user_time(char *ptr, char *tty)
 {
        time_t real, diff, log_in;
        char buf[BUFLEN] = "";
@@ -111,11 +111,7 @@ static void tty_user_time(char *ptr, char *tty, char times_in_seconds)
 
        time(&real);
        diff = difftime(real, log_in);
-       if(times_in_seconds) {
-               snprintf(buf, BUFLEN, "%d", (int) diff);
-       } else {
-               format_seconds(buf, BUFLEN, diff);
-       }
+       format_seconds(buf, BUFLEN, diff);
        strncpy(ptr, buf, BUFLEN-1);
 }
 
@@ -133,7 +129,7 @@ static void users_alloc(struct information *ptr)
        }
 }
 
-void update_user_time(char *tty, char times_in_seconds)
+void update_user_time(char *tty)
 {
        struct information *current_info = &info;
        char temp[BUFLEN] = "";
@@ -142,7 +138,7 @@ void update_user_time(char *tty, char times_in_seconds)
                current_info->users.ctime = malloc(text_buffer_size);
        }
 
-       tty_user_time(temp, tty, times_in_seconds);
+       tty_user_time(temp, tty);
 
        if (temp != NULL) {
                if (current_info->users.ctime) {
@@ -161,7 +157,7 @@ void update_user_time(char *tty, char times_in_seconds)
        }
 }
 
-void update_users(void)
+int update_users(void)
 {
        struct information *current_info = &info;
        char temp[BUFLEN] = "";
@@ -225,4 +221,5 @@ void update_users(void)
                current_info->users.times = malloc(text_buffer_size);
                strncpy(current_info->users.times, "broken", text_buffer_size);
        }
+       return 0;
 }