--- projects/libstatgrab/src/libstatgrab/user_stats.c 2005/09/24 13:29:23 1.28 +++ projects/libstatgrab/src/libstatgrab/user_stats.c 2010/02/20 17:55:04 1.29 @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA * - * $Id: user_stats.c,v 1.28 2005/09/24 13:29:23 tdb Exp $ + * $Id: user_stats.c,v 1.29 2010/02/20 17:55:04 tdb Exp $ */ #ifdef HAVE_CONFIG_H @@ -40,8 +40,12 @@ #include #endif #ifndef WIN32 +#ifdef HAVE_UTMPX +#include +#else #include #endif +#endif #ifdef CYGWIN #include #endif @@ -57,7 +61,7 @@ sg_user_stats *sg_get_user_stats(){ int num_users = 0, pos = 0, new_pos; VECTOR_DECLARE_STATIC(name_list, char, 128, NULL, NULL); static sg_user_stats user_stats; -#ifdef ALLBSD +#if defined(ALLBSD) && !defined(HAVE_UTMPX) struct utmp entry; FILE *f; @@ -132,10 +136,15 @@ sg_user_stats *sg_get_user_stats(){ } #else /* This works on everything else. */ +#ifdef HAVE_UTMPX + struct utmpx *entry; + setutxent(); + while((entry=getutxent()) != NULL) { +#else struct utmp *entry; - setutent(); while((entry=getutent()) != NULL) { +#endif if (entry->ut_type != USER_PROCESS) continue; new_pos = pos + strlen(entry->ut_user) + 1; @@ -148,7 +157,11 @@ sg_user_stats *sg_get_user_stats(){ pos = new_pos; num_users++; } +#ifdef HAVE_UTMPX + endutxent(); +#else endutent(); +#endif #endif /* Remove the extra space at the end, and append a \0. */