ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/ihost/libstatgrab/user_stats.c
(Generate patch)

Comparing projects/cms/source/ihost/libstatgrab/user_stats.c (file contents):
Revision 1.1 by pajs, Mon May 13 16:07:53 2002 UTC vs.
Revision 1.6 by pajs, Tue May 21 16:16:41 2002 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * Copyright (C) 2000-2002 i-scream
4 + *
5 + * This program is free software; you can redistribute it and/or
6 + * modify it under the terms of the GNU General Public License
7 + * as published by the Free Software Foundation; either version 2
8 + * of the License, or (at your option) any later version.
9 + *
10 + * This program is distributed in the hope that it will be useful,
11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 + * GNU General Public License for more details.
14 + *
15 + * You should have received a copy of the GNU General Public License
16 + * along with this program; if not, write to the Free Software
17 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 + */
19 +
20   #include "ukcprog.h"
21   #include <stdlib.h>
22   #include <stdio.h>
# Line 21 | Line 40 | char *get_user_stats(){
40   #endif
41  
42   #if defined(LINUX) || defined(SOLARIS)
43 +        setutent();
44          while((entry=getutent()) != NULL) {
45                  if(entry->ut_type==USER_PROCESS) {
46                          user_tmp=user_list;
# Line 33 | Line 53 | char *get_user_stats(){
53                          nousers++;
54                  }
55          }
56 +        endutent();
57   #endif
58  
59   #ifdef FREEBSD
# Line 52 | Line 73 | char *get_user_stats(){
73                  if(user_tmp!=NULL) free(user_tmp);
74                  nousers++;
75          }
76 +
77 +        if ((fclose(f)) != 0) {
78 +                errf("Failed to close file (%m)");
79 +                return NULL;
80 +        }
81 +
82   #endif
83 <        if (user_list==NULL) user_list=strdup("");
84 <        xml_user_data=strf("<users><list>%s</list><count>%d</count></users>",user_list,nousers);
85 <        if (user_list==NULL) free(user_list);
83 >        if (user_list==NULL){
84 >                if((user_list=strdup("")) == NULL){
85 >                        errf("strdup failed (%m)");
86 >                        return NULL;
87 >                }
88 >        }
89 >        if((xml_user_data=strf("<users><list>%s</list><count>%d</count></users>",user_list,nousers)) == NULL){
90 >                errf("strf failed (%m)");
91 >                return NULL;
92 >        }
93 >        if (user_list!=NULL) free(user_list);
94          return xml_user_data;
95   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines