new top routines using linked lists instead of arrays
[monky] / src / top.h
1 /*
2  * top.c a slightly modified wmtop.c -- copied from the WindowMaker and gkrelltop
3  * 
4  * Modified by Brenden Matthews
5  *
6  * Modified by Adi Zaimi
7  *
8  * Derived by Dan Piponi dan@tanelorn.demon.co.uk
9  * http://www.tanelorn.demon.co.uk
10  * http://wmtop.sourceforge.net 
11  * from code originally contained in wmsysmon by Dave Clark 
12 (clarkd@skynet.ca)
13  * This software is licensed through the GNU General Public License.
14  
15  *  $Id$
16  */
17
18 /*
19  * Ensure there's an operating system defined. There is *no* default
20  * because every OS has it's own way of revealing CPU/memory usage.
21  * compile with gcc -DOS ...
22  */
23
24 /******************************************/
25 /* Includes                               */
26 /******************************************/
27
28 #include "conky.h"
29 #define CPU_THRESHHOLD   0      /* threshhold for the cpu diff to appear */
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <time.h>
33 #include <dirent.h>
34 #include <string.h>
35 #include <fcntl.h>
36 #include <unistd.h>
37 #include <ctype.h>
38 #include <math.h>
39 #include <assert.h>
40 #include <limits.h>
41 #include <errno.h>
42 #include <signal.h>
43
44 #include <sys/wait.h>
45 #include <sys/stat.h>
46 #include <sys/param.h>
47 #include <sys/types.h>
48 #include <sys/ioctl.h>
49 #include <sys/time.h>
50
51 #include <regex.h>
52
53 /******************************************/
54 /* Defines                                */
55 /******************************************/
56
57
58 /*
59  * XXX: I shouldn't really use this BUFFER_LEN variable but scanf is so
60  * lame and it'll take me a while to write a replacement.
61  */
62 #define BUFFER_LEN 1024
63
64 #define PROCFS_TEMPLATE "/proc/%d/stat"
65 #define PROCFS_TEMPLATE_MEM "/proc/%d/statm"
66 #define PROCFS_CMDLINE_TEMPLATE "/proc/%d/cmdline"
67 #define MAX_SP 10  //number of elements to sort
68
69
70 /******************************************/
71 /* Globals                                */
72 /******************************************/
73
74 /******************************************/
75 /* Process class                          */
76 /******************************************/
77
78 struct sorted_process {
79         struct sorted_process *greater;
80         struct sorted_process *less;    
81         struct process *proc;
82 }; 
83
84 /*
85  * Pointer to head of process list
86  */
87 void process_find_top(struct process **, struct process **);