Moved struct process to top.h
[monky] / src / top.h
1 /* Conky, a system monitor, based on torsmo
2  *
3  * Any original torsmo code is licensed under the BSD license
4  *
5  * All code written since the fork of torsmo is licensed under the GPL
6  *
7  * Please see COPYING for details
8  *
9  * Copyright (c) 2005 Adi Zaimi, Dan Piponi <dan@tanelorn.demon.co.uk>,
10  *                                        Dave Clark <clarkd@skynet.ca>
11  * Copyright (c) 2005-2008 Brenden Matthews, Philip Kovacs, et. al.
12  *      (see AUTHORS)
13  * All rights reserved.
14  *
15  * This program is free software: you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation, either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  * You should have received a copy of the GNU General Public License
25  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
26  *
27  * $Id$ */
28
29 #ifndef _top_h_
30 #define _top_h_
31
32 /* Ensure there's an operating system defined.
33  * compile with gcc -DOS ...
34  * There is *no* default because every OS has it's own way of revealing
35  * CPU/memory usage. */
36
37 /******************************************
38  * Includes                                                               *
39  ******************************************/
40
41 #include "conky.h"
42 #define CPU_THRESHHOLD  0       /* threshhold for the cpu diff to appear */
43 #include <stdlib.h>
44 #include <stdio.h>
45 #include <time.h>
46 #include <dirent.h>
47 #include <string.h>
48 #include <fcntl.h>
49 #include <unistd.h>
50 #include <ctype.h>
51 #include <math.h>
52 #include <assert.h>
53 #include <limits.h>
54 #include <errno.h>
55 #include <signal.h>
56
57 #include <sys/wait.h>
58 #include <sys/stat.h>
59 #include <sys/param.h>
60 #include <sys/types.h>
61 #include <sys/ioctl.h>
62 #include <sys/time.h>
63
64 #include <regex.h>
65
66 /******************************************
67  * Defines                                                                *
68  ******************************************/
69
70 /* XXX: I shouldn't really use this BUFFER_LEN variable but scanf is so lame
71  * and it'll take me a while to write a replacement. */
72 #define BUFFER_LEN 1024
73
74 #define PROCFS_TEMPLATE "/proc/%d/stat"
75 #define PROCFS_TEMPLATE_MEM "/proc/%d/statm"
76 #define PROCFS_CMDLINE_TEMPLATE "/proc/%d/cmdline"
77 #define MAX_SP 10       // number of elements to sort
78
79 /******************************************
80  * Process class                                                  *
81  ******************************************/
82
83 struct process {
84         struct process *next;
85         struct process *previous;
86
87         pid_t pid;
88         char *name;
89         float amount;
90         // User and kernel times are in hundredths of seconds
91         unsigned long user_time;
92         unsigned long total;
93         unsigned long kernel_time;
94         unsigned long previous_user_time;
95         unsigned long previous_kernel_time;
96         unsigned long total_cpu_time;
97         unsigned int vsize;
98         unsigned int rss;
99         unsigned int time_stamp;
100         unsigned int counted;
101         unsigned int changed;
102         float totalmem;
103 };
104
105 struct sorted_process {
106         struct sorted_process *greater;
107         struct sorted_process *less;
108         struct process *proc;
109 };
110
111 /* Pointer to head of process list */
112 void process_find_top(struct process **, struct process **);
113
114 #endif /* _top_h_ */