Bugfix: $addr and $addrs couldn't find ip's before the first update.
[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-2009 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 #define DEFAULT_BAR_WIDTH_NO_X 10
47
48 #if !defined(__GNUC__)
49 #  define __attribute__(x) /* nothing */
50 #endif
51
52 #ifndef HAVE_STRNDUP
53 // use our own strndup() if it's not available
54 char *strndup(const char *s, size_t n);
55 #endif /* HAVE_STRNDUP */
56
57 /* headers of optional features
58  * include them here, so we don't need to run the check
59  * in every code file optionally using the feature
60  */
61
62 #ifdef AUDACIOUS
63 #include "audacious.h"
64 #endif
65
66 #ifdef BMPX
67 #include "bmpx.h"
68 #endif
69
70 #ifdef EVE
71 #include "eve.h"
72 #endif
73
74 #ifdef HDDTEMP
75 #include "hddtemp.h"
76 #endif /* HDDTEMP */
77
78 #ifdef MOC
79 #include "moc.h"
80 #endif
81
82 #ifdef MPD
83 #include "mpd.h"
84 #endif
85
86 #ifdef NVIDIA
87 #include "nvidia.h"
88 #endif
89
90 #ifdef RSS
91 #include "rss.h"
92 #endif
93
94 #ifdef HAVE_LUA
95 #include "llua.h"
96 #endif
97
98 #ifdef TCP_PORT_MONITOR
99 #include "tcp-portmon.h"
100 #endif
101
102 #ifdef XMMS2
103 #include "xmms2.h"
104 #endif
105
106 #ifdef IBM
107 #include "ibm.h"
108 #include "smapi.h"
109 #endif
110
111 #ifdef APCUPSD
112 #include "apcupsd.h"
113 #endif
114
115 /* sony support */
116 #include "sony.h"
117
118 /* A size for temporary, static buffers to use when
119  * one doesn't know what to choose. Defaults to 256.  */
120 extern unsigned int text_buffer_size;
121
122 struct entropy_s {
123         unsigned int entropy_avail;
124         unsigned int poolsize;
125 };
126
127 struct usr_info {
128         char *names;
129         char *times;
130         char *terms;
131         int number;
132 };
133
134 struct gateway_info {
135         char *iface;
136         char *ip;
137         int count;
138 };
139
140 #ifdef X11
141 struct monitor_info {
142         int number;
143         int current;
144 };
145
146 struct x11_info {
147         struct monitor_info monitor;
148 };
149 #endif
150
151 enum {
152         INFO_CPU = 0,
153         INFO_MAIL = 1,
154         INFO_MEM = 2,
155         INFO_NET = 3,
156         INFO_PROCS = 4,
157         INFO_RUN_PROCS = 5,
158         INFO_UPTIME = 6,
159         INFO_BUFFERS = 7,
160         INFO_FS = 8,
161         INFO_SYSFS = 9,
162         INFO_MIXER = 10,
163         INFO_LOADAVG = 11,
164         INFO_UNAME = 12,
165         INFO_FREQ = 13,
166 #ifdef MPD
167         INFO_MPD = 14,
168 #endif
169         INFO_TOP = 15,
170         INFO_WIFI = 16,
171         INFO_DISKIO = 17,
172         INFO_I8K = 18,
173 #ifdef TCP_PORT_MONITOR
174         INFO_TCP_PORT_MONITOR = 19,
175 #endif
176 #ifdef AUDACIOUS
177         INFO_AUDACIOUS = 20,
178 #endif
179 #ifdef BMPX
180         INFO_BMPX = 21,
181 #endif
182 #ifdef XMMS2
183         INFO_XMMS2 = 22,
184 #endif
185         INFO_ENTROPY = 23,
186 #ifdef RSS
187         INFO_RSS = 24,
188 #endif
189 #ifdef IBM
190         INFO_SMAPI = 25,
191 #endif
192         INFO_USERS = 26,
193         INFO_GW = 27,
194 #ifdef NVIDIA
195         INFO_NVIDIA = 28,
196 #endif
197 #ifdef X11
198         INFO_X11 = 29,
199 #endif
200         INFO_DNS = 30,
201 #ifdef MOC
202         INFO_MOC = 31,
203 #endif
204 #ifdef APCUPSD
205         INFO_APCUPSD = 32,
206 #endif
207 };
208
209 /* get_battery_stuff() item selector
210  * needed by conky.c, linux.c and freebsd.c */
211 enum {
212         BATTERY_STATUS,
213         BATTERY_TIME
214 };
215
216 /* if_up strictness selector
217  * needed by conky.c and linux.c (and potentially others) */
218 enum {
219         IFUP_UP,
220         IFUP_LINK,
221         IFUP_ADDR
222 } ifup_strictness;
223
224 struct information {
225         unsigned int mask;
226
227         struct utsname uname_s;
228
229         char freq[10];
230
231         double uptime;
232
233         /* memory information in kilobytes */
234         unsigned long long mem, memeasyfree, memfree, memmax, swap, swapmax;
235         unsigned long long bufmem, buffers, cached;
236
237         unsigned short procs;
238         unsigned short run_procs;
239
240         float *cpu_usage;
241         /* struct cpu_stat cpu_summed; what the hell is this? */
242         unsigned int cpu_count;
243         int cpu_avg_samples;
244
245         int net_avg_samples;
246
247         int diskio_avg_samples;
248
249         float loadavg[3];
250
251         struct mail_s *mail;
252         int mail_running;
253 #ifdef XMMS2
254         struct xmms2_s xmms2;
255 #endif
256 #ifdef AUDACIOUS
257         AUDACIOUS_S audacious;
258 #endif
259 #ifdef BMPX
260         struct bmpx_s bmpx;
261 #endif
262         struct usr_info users;
263         struct gateway_info gw_info;
264         struct dns_data nameserver_info;
265         struct process *cpu[10];
266         struct process *memu[10];
267         struct process *time[10];
268         struct process *first_process;
269         unsigned long looped;
270         struct entropy_s entropy;
271         double music_player_interval;
272
273 #ifdef X11
274         struct x11_info x11;
275 #endif
276
277 #ifdef APCUPSD
278         APCUPSD_S apcupsd;
279 #endif
280
281         short kflags;   /* kernel settings, see enum KFLAG */
282 };
283
284 /* needed by linux.c and top.c -> outsource somewhere */
285 enum {
286         /* set to true if kernel uses "long" format for /proc/stats */
287         KFLAG_IS_LONGSTAT = 0x01,
288         /* set to true if kernel shows # of threads for the proc value
289          * in sysinfo() call */
290         KFLAG_PROC_IS_THREADS = 0x02
291         /* bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
292         /* KFLAG_NEXT_ONE = 0x04 */
293 };
294 #define KFLAG_SETON(a) info.kflags |= a
295 #define KFLAG_SETOFF(a) info.kflags &= (~a)
296 #define KFLAG_FLIP(a) info.kflags ^= a
297 #define KFLAG_ISSET(a) info.kflags & a
298
299 /* defined in conky.c, needed by top.c */
300 extern int top_cpu, top_mem, top_time;
301
302 /* defined in conky.c, needed by top.c */
303 extern int cpu_separate;
304
305 /* struct that has all info to be shared between
306  * instances of the same text object */
307 extern struct information info;
308
309 /* defined in users.c */
310 void update_users(void);
311
312 /* defined in conky.c */
313 extern double current_update_time, last_update_time, update_interval;
314
315 /* defined in conky.c */
316 int spaced_print(char *, int, const char *, int, ...)
317         __attribute__((format(printf, 3, 5)));
318 extern int inotify_fd;
319
320 #ifdef X11
321 #define TO_X 1
322 #endif
323 #define TO_STDOUT 2
324 #define TO_STDERR 4
325 #define OVERWRITE_FILE 8
326 #define APPEND_FILE 16
327 enum x_initialiser_state {
328         NO = 0,
329         YES = 1,
330         NEVER = 2
331 };
332 extern int output_methods;
333 extern enum x_initialiser_state x_initialised;
334
335 int total_updates;
336
337 #define DEFAULT_TEXT_BUFFER_SIZE_S "##DEFAULT_TEXT_BUFFER_SIZE"
338
339 #endif /* _conky_h_ */