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.3 by tdb, Sat May 18 18:15:56 2002 UTC vs.
Revision 1.6 by pajs, Tue May 21 16:16:41 2002 UTC

# Line 40 | 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 52 | Line 53 | char *get_user_stats(){
53                          nousers++;
54                  }
55          }
56 +        endutent();
57   #endif
58  
59   #ifdef FREEBSD
# Line 71 | 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);
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