40 |
|
#include <sys/param.h> |
41 |
|
#endif |
42 |
|
#ifndef WIN32 |
43 |
+ |
#ifdef HAVE_UTMPX |
44 |
+ |
#include <utmpx.h> |
45 |
+ |
#else |
46 |
|
#include <utmp.h> |
47 |
|
#endif |
48 |
+ |
#endif |
49 |
|
#ifdef CYGWIN |
50 |
|
#include <sys/unistd.h> |
51 |
|
#endif |
61 |
|
int num_users = 0, pos = 0, new_pos; |
62 |
|
VECTOR_DECLARE_STATIC(name_list, char, 128, NULL, NULL); |
63 |
|
static sg_user_stats user_stats; |
64 |
< |
#ifdef ALLBSD |
64 |
> |
#if defined(ALLBSD) && !defined(HAVE_UTMPX) |
65 |
|
struct utmp entry; |
66 |
|
FILE *f; |
67 |
|
|
136 |
|
} |
137 |
|
#else |
138 |
|
/* This works on everything else. */ |
139 |
+ |
#ifdef HAVE_UTMPX |
140 |
+ |
struct utmpx *entry; |
141 |
+ |
setutxent(); |
142 |
+ |
while((entry=getutxent()) != NULL) { |
143 |
+ |
#else |
144 |
|
struct utmp *entry; |
136 |
– |
|
145 |
|
setutent(); |
146 |
|
while((entry=getutent()) != NULL) { |
147 |
+ |
#endif |
148 |
|
if (entry->ut_type != USER_PROCESS) continue; |
149 |
|
|
150 |
|
new_pos = pos + strlen(entry->ut_user) + 1; |
157 |
|
pos = new_pos; |
158 |
|
num_users++; |
159 |
|
} |
160 |
+ |
#ifdef HAVE_UTMPX |
161 |
+ |
endutxent(); |
162 |
+ |
#else |
163 |
|
endutent(); |
164 |
+ |
#endif |
165 |
|
#endif |
166 |
|
|
167 |
|
/* Remove the extra space at the end, and append a \0. */ |