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.4 by pajs, Sun May 19 15:07:51 2002 UTC vs.
Revision 1.8 by tdb, Wed May 29 19:41:59 2002 UTC

# Line 1 | Line 1
1   /*
2   * i-scream central monitoring system
3 + * http://www.i-scream.org.uk
4   * Copyright (C) 2000-2002 i-scream
5   *
6   * This program is free software; you can redistribute it and/or
# Line 17 | Line 18
18   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19   */
20  
21 + #ifdef HAVE_CONFIG_H
22 + #include "config.h"
23 + #endif
24 +
25   #include "ukcprog.h"
26   #include <stdlib.h>
27   #include <stdio.h>
# Line 40 | Line 45 | char *get_user_stats(){
45   #endif
46  
47   #if defined(LINUX) || defined(SOLARIS)
48 +        setutent();
49          while((entry=getutent()) != NULL) {
50                  if(entry->ut_type==USER_PROCESS) {
51                          user_tmp=user_list;
# Line 52 | Line 58 | char *get_user_stats(){
58                          nousers++;
59                  }
60          }
61 +        endutent();
62   #endif
63  
64   #ifdef FREEBSD
# Line 78 | Line 85 | char *get_user_stats(){
85          }
86  
87   #endif
88 <        if (user_list==NULL) user_list=strdup("");
89 <        xml_user_data=strf("<users><list>%s</list><count>%d</count></users>",user_list,nousers);
88 >        if (user_list==NULL){
89 >                if((user_list=strdup("")) == NULL){
90 >                        errf("strdup failed (%m)");
91 >                        return NULL;
92 >                }
93 >        }
94 >        if((xml_user_data=strf("<users><list>%s</list><count>%d</count></users>",user_list,nousers)) == NULL){
95 >                errf("strf failed (%m)");
96 >                return NULL;
97 >        }
98          if (user_list!=NULL) free(user_list);
99          return xml_user_data;
100   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines