simplify diskio stats
[monky] / src / conky.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) 2004, Hannu Saransaari and Lauri Hakkarainen
10  * Copyright (c) 2005-2008 Brenden Matthews, Philip Kovacs, et. al.
11  *      (see AUTHORS)
12  * All rights reserved.
13  *
14  * This program is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation, either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  * You should have received a copy of the GNU General Public License
24  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25  *
26  */
27
28 #ifndef _conky_h_
29 #define _conky_h_
30
31 #include "config.h"     /* defines */
32 #include "common.h"     /* at least for struct dns_data */
33 #include <sys/utsname.h> /* struct uname_s */
34
35 #if defined(HAS_MCHECK_H)
36 #include <mcheck.h>
37 #endif /* HAS_MCHECK_H */
38
39 #undef EQUAL
40 #undef FALSE
41 #undef TRUE
42 #define EQUAL 0 //returnvalue of strcmp-variants when strings are equal
43 #define FALSE 0
44 #define TRUE 1
45
46
47 #if !defined(__GNUC__)
48 #  define __attribute__(x) /* nothing */
49 #endif
50
51 #ifndef HAVE_STRNDUP
52 // use our own strndup() if it's not available
53 char *strndup(const char *s, size_t n);
54 #endif /* HAVE_STRNDUP */
55
56 /* headers of optional features
57  * include them here, so we don't need to run the check
58  * in every code file optionally using the feature
59  */
60
61 #ifdef AUDACIOUS
62 #include "audacious.h"
63 #endif
64
65 #ifdef BMPX
66 #include "bmpx.h"
67 #endif
68
69 #ifdef EVE
70 #include "eve.h"
71 #endif
72
73 #ifdef HDDTEMP
74 #include "hddtemp.h"
75 #endif /* HDDTEMP */
76
77 #ifdef MOC
78 #include "moc.h"
79 #endif
80
81 #ifdef MPD
82 #include "mpd.h"
83 #endif
84
85 #ifdef NVIDIA
86 #include "nvidia.h"
87 #endif
88
89 #ifdef RSS
90 #include "rss.h"
91 #endif
92
93 #ifdef SMAPI
94 #include "smapi.h"
95 #endif
96
97 #ifdef TCP_PORT_MONITOR
98 #include "tcp-portmon.h"
99 #endif
100
101 #ifdef XMMS2
102 #include "xmms2.h"
103 #endif
104
105 /* A size for temporary, static buffers to use when
106  * one doesn't know what to choose. Defaults to 256.  */
107 extern unsigned int text_buffer_size;
108
109 struct entropy_s {
110         unsigned int entropy_avail;
111         unsigned int poolsize;
112 };
113
114 struct usr_info {
115         char *names;
116         char *times;
117         char *terms;
118         int number;
119 };
120
121 struct gateway_info {
122         char *iface;
123         char *ip;
124         int count;
125 };
126
127 #ifdef X11
128 struct monitor_info {
129         int number;
130         int current;
131 };
132
133 struct x11_info {
134         struct monitor_info monitor;
135 };
136 #endif
137
138 enum {
139         INFO_CPU = 0,
140         INFO_MAIL = 1,
141         INFO_MEM = 2,
142         INFO_NET = 3,
143         INFO_PROCS = 4,
144         INFO_RUN_PROCS = 5,
145         INFO_UPTIME = 6,
146         INFO_BUFFERS = 7,
147         INFO_FS = 8,
148         INFO_SYSFS = 9,
149         INFO_MIXER = 10,
150         INFO_LOADAVG = 11,
151         INFO_UNAME = 12,
152         INFO_FREQ = 13,
153 #ifdef MPD
154         INFO_MPD = 14,
155 #endif
156         INFO_TOP = 15,
157         INFO_WIFI = 16,
158         INFO_DISKIO = 17,
159         INFO_I8K = 18,
160 #ifdef TCP_PORT_MONITOR
161         INFO_TCP_PORT_MONITOR = 19,
162 #endif
163 #ifdef AUDACIOUS
164         INFO_AUDACIOUS = 20,
165 #endif
166 #ifdef BMPX
167         INFO_BMPX = 21,
168 #endif
169 #ifdef XMMS2
170         INFO_XMMS2 = 22,
171 #endif
172         INFO_ENTROPY = 23,
173 #ifdef RSS
174         INFO_RSS = 24,
175 #endif
176 #ifdef SMAPI
177         INFO_SMAPI = 25,
178 #endif
179         INFO_USERS = 26,
180         INFO_GW = 27,
181 #ifdef NVIDIA
182         INFO_NVIDIA = 28,
183 #endif
184 #ifdef X11
185         INFO_X11 = 29,
186 #endif
187         INFO_DNS = 30,
188 #ifdef MOC
189   INFO_MOC = 31
190 #endif
191 };
192
193 /* get_battery_stuff() item selector
194  * needed by conky.c, linux.c and freebsd.c */
195 enum {
196         BATTERY_STATUS,
197         BATTERY_TIME
198 };
199
200 /* if_up strictness selector
201  * needed by conky.c and linux.c (and potentially others) */
202 enum {
203         IFUP_UP,
204         IFUP_LINK,
205         IFUP_ADDR
206 } ifup_strictness;
207
208 struct information {
209         unsigned int mask;
210
211         struct utsname uname_s;
212
213         char freq[10];
214
215         double uptime;
216
217         /* memory information in kilobytes */
218         unsigned long long mem, memeasyfree, memfree, memmax, swap, swapmax;
219         unsigned long long bufmem, buffers, cached;
220
221         unsigned short procs;
222         unsigned short run_procs;
223
224         float *cpu_usage;
225         /* struct cpu_stat cpu_summed; what the hell is this? */
226         unsigned int cpu_count;
227         unsigned int cpu_avg_samples;
228
229         unsigned int net_avg_samples;
230
231         float loadavg[3];
232
233         struct mail_s *mail;
234         int mail_running;
235 #ifdef MPD
236         struct mpd_s mpd;
237 #endif
238 #ifdef MOC
239   struct moc_s moc;
240 #endif
241 #ifdef XMMS2
242         struct xmms2_s xmms2;
243         int xmms2_conn_state;
244         xmms_socket_t xmms2_fd;
245         fd_set xmms2_fdset;
246         xmmsc_connection_t *xmms2_conn;
247 #endif
248 #ifdef AUDACIOUS
249         AUDACIOUS_S audacious;
250 #endif
251 #ifdef BMPX
252         struct bmpx_s bmpx;
253 #endif
254         struct usr_info users;
255         struct gateway_info gw_info;
256         struct dns_data nameserver_info;
257         struct process *cpu[10];
258         struct process *memu[10];
259         struct process *first_process;
260         unsigned long looped;
261         struct entropy_s entropy;
262         double music_player_interval;
263
264 #ifdef X11
265         struct x11_info x11;
266 #endif
267
268         short kflags;   /* kernel settings, see enum KFLAG */
269 };
270
271 /* needed by linux.c and top.c -> outsource somewhere */
272 enum {
273         /* set to true if kernel uses "long" format for /proc/stats */
274         KFLAG_IS_LONGSTAT = 0x01,
275         /* set to true if kernel shows # of threads for the proc value
276          * in sysinfo() call */
277         KFLAG_PROC_IS_THREADS = 0x02
278         /* bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
279         /* KFLAG_NEXT_ONE = 0x04 */
280 };
281 #define KFLAG_SETON(a) info.kflags |= a
282 #define KFLAG_SETOFF(a) info.kflags &= (~a)
283 #define KFLAG_FLIP(a) info.kflags ^= a
284 #define KFLAG_ISSET(a) info.kflags & a
285
286 /* defined in conky.c, needed by top.c */
287 extern int top_cpu, top_mem;
288
289 enum spacer_opts { NO_SPACER = 0, LEFT_SPACER, RIGHT_SPACER };
290
291 /* defined in conky.c, needed by top.c */
292 extern int cpu_separate;
293
294 /* struct that has all info to be shared between
295  * instances of the same text object */
296 extern struct information info;
297
298 /* defined in users.c */
299 void update_users(void);
300
301 /* defined in conky.c */
302 extern double current_update_time, last_update_time;
303
304 #endif