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

Comparing projects/libstatgrab/src/libstatgrab/process_stats.c (file contents):
Revision 1.80 by ats, Sun Nov 7 12:32:24 2004 UTC vs.
Revision 1.81 by tdb, Sat Sep 24 13:29:22 2005 UTC

# Line 78 | Line 78
78   #include <unistd.h>
79   #define PROCESS_BATCH 30
80   #endif
81 + #ifdef WIN32
82 + #include <windows.h>
83 + #include <psapi.h>
84 + #endif
85  
86   static void proc_state_init(sg_process_stats *s) {
87          s->process_name = NULL;
# Line 755 | Line 759 | sg_process_stats *sg_get_process_stats(int *entries){
759          sg_set_error(SG_ERROR_UNSUPPORTED, "Cygwin");
760          return NULL;
761   #endif
762 + #ifdef WIN32
763 +        /* FIXME The data needed for this is probably do able with the
764 +         * "performance registry". Although using this appears to be a black
765 +         * art and closely guarded secret.
766 +         * This is not directly used in ihost, so not considered a priority */
767 +        sg_set_error(SG_ERROR_UNSUPPORTED, "Win32");
768 +        return NULL;
769 + #endif
770  
771          *entries = proc_state_size;
772          return proc_state;
# Line 762 | Line 774 | sg_process_stats *sg_get_process_stats(int *entries){
774  
775   sg_process_count *sg_get_process_count() {
776          static sg_process_count process_stat;
777 + #ifndef WIN32
778          sg_process_stats *ps;
779          int ps_size, x;
780 + #else
781 +        DWORD aProcesses[1024];
782 +        DWORD cbNeeded;
783 + #endif
784  
785          process_stat.sleeping = 0;
786          process_stat.running = 0;
# Line 771 | Line 788 | sg_process_count *sg_get_process_count() {
788          process_stat.stopped = 0;
789          process_stat.total = 0;
790  
791 + #ifndef WIN32
792          ps = sg_get_process_stats(&ps_size);
793          if (ps == NULL) {
794                  return NULL;
# Line 799 | Line 817 | sg_process_count *sg_get_process_count() {
817          }
818  
819          process_stat.total = ps_size;
820 + #else
821 +        if (!EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded))
822 +                return NULL;
823 +        process_stat.total = cbNeeded / sizeof(DWORD);
824 + #endif
825  
826          return &process_stat;
827   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines