1 |
|
/* |
2 |
< |
* i-scream central monitoring system |
2 |
> |
* i-scream libstatgrab |
3 |
|
* http://www.i-scream.org |
4 |
|
* Copyright (C) 2000-2004 i-scream |
5 |
|
* |
44 |
|
#include <sys/unistd.h> |
45 |
|
#endif |
46 |
|
|
47 |
< |
user_stat_t *get_user_stats(){ |
47 |
> |
sg_user_stats *sg_get_user_stats(){ |
48 |
|
int num_users = 0, pos = 0, new_pos; |
49 |
|
VECTOR_DECLARE_STATIC(name_list, char, 128, NULL, NULL); |
50 |
< |
static user_stat_t user_stats; |
50 |
> |
static sg_user_stats user_stats; |
51 |
|
#if defined(SOLARIS) || defined(LINUX) || defined(CYGWIN) |
52 |
|
struct utmp *entry; |
53 |
|
#endif |
54 |
|
#ifdef ALLBSD |
55 |
|
struct utmp entry; |
56 |
< |
FILE *f; |
56 |
> |
FILE *f; |
57 |
|
#endif |
58 |
|
|
59 |
|
#if defined(SOLARIS) || defined(LINUX) || defined(CYGWIN) |
75 |
|
#endif |
76 |
|
#ifdef ALLBSD |
77 |
|
if ((f=fopen(_PATH_UTMP, "r")) == NULL){ |
78 |
+ |
sg_set_error(SG_ERROR_OPEN, _PATH_UTMP); |
79 |
|
return NULL; |
80 |
|
} |
81 |
|
while((fread(&entry, sizeof(entry),1,f)) != 0){ |
98 |
|
if (num_users != 0) { |
99 |
|
pos--; |
100 |
|
} |
101 |
< |
VECTOR_RESIZE(name_list, pos + 1); |
101 |
> |
if (VECTOR_RESIZE(name_list, pos + 1) < 0) { |
102 |
> |
return NULL; |
103 |
> |
} |
104 |
|
name_list[pos] = '\0'; |
105 |
|
|
106 |
|
user_stats.num_entries = num_users; |