Fix buildproblems introduced by 3f4127080e0577c71c42ad487f8a9435c761329c . inet.h...
[monky] / src / conky.h
1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
2  *
3  * Conky, a system monitor, based on torsmo
4  *
5  * Any original torsmo code is licensed under the BSD license
6  *
7  * All code written since the fork of torsmo is licensed under the GPL
8  *
9  * Please see COPYING for details
10  *
11  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
12  * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
13  *      (see AUTHORS)
14  * All rights reserved.
15  *
16  * This program is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  * You should have received a copy of the GNU General Public License
26  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
27  *
28  * vim: ts=4 sw=4 noet ai cindent syntax=c
29  *
30  */
31
32 #ifndef _conky_h_
33 #define _conky_h_
34
35 #include "config.h"     /* defines */
36 #include "common.h"     /* at least for struct dns_data */
37 #include <sys/utsname.h> /* struct uname_s */
38 #include <arpa/inet.h>
39
40 #if defined(HAS_MCHECK_H)
41 #include <mcheck.h>
42 #endif /* HAS_MCHECK_H */
43
44 #undef EQUAL
45 #undef FALSE
46 #undef TRUE
47 #define EQUAL 0 //returnvalue of strcmp-variants when strings are equal
48 #define FALSE 0
49 #define TRUE 1
50
51 #define DEFAULT_BAR_WIDTH_NO_X 10
52
53 #if !defined(__GNUC__)
54 #  define __attribute__(x) /* nothing */
55 #endif
56
57 #ifndef HAVE_STRNDUP
58 // use our own strndup() if it's not available
59 char *strndup(const char *s, size_t n);
60 #endif /* HAVE_STRNDUP */
61
62 /* headers of optional features
63  * include them here, so we don't need to run the check
64  * in every code file optionally using the feature
65  */
66
67 #ifdef AUDACIOUS
68 #include "audacious.h"
69 #endif
70
71 #ifdef BMPX
72 #include "bmpx.h"
73 #endif
74
75 #ifdef EVE
76 #include "eve.h"
77 #endif
78
79 #ifdef HDDTEMP
80 #include "hddtemp.h"
81 #endif /* HDDTEMP */
82
83 #ifdef MOC
84 #include "moc.h"
85 #endif
86
87 #ifdef MPD
88 #include "mpd.h"
89 #endif
90
91 #ifdef NVIDIA
92 #include "nvidia.h"
93 #endif
94
95 #ifdef HAVE_CURL
96 #include "ccurl_thread.h"
97 #endif /* HAVE_CURL */
98
99 #ifdef RSS
100 #include "rss.h"
101 #endif /* RSS */
102
103 #ifdef XOAP
104 #ifndef WEATHER
105 #error "WEATHER needs to be defined if XOAP is defined"
106 #endif /* WEATHER */
107 #endif /* XOAP */
108
109 #ifdef WEATHER
110 #include "weather.h"
111 #endif /* WEATHER */
112
113 #ifdef TCP_PORT_MONITOR
114 #include "tcp-portmon.h"
115 #endif
116
117 #ifdef XMMS2
118 #include "xmms2.h"
119 #endif
120
121 #ifdef IBM
122 #include "ibm.h"
123 #include "smapi.h"
124 #endif
125
126 #ifdef APCUPSD
127 #include "apcupsd.h"
128 #endif
129
130 #ifdef NCURSES
131 #include <ncurses.h>
132 #endif
133
134 /* sony support */
135 #include "sony.h"
136
137 /* A size for temporary, static buffers to use when
138  * one doesn't know what to choose. Defaults to 256.  */
139 extern unsigned int text_buffer_size;
140
141 struct entropy_s {
142         unsigned int entropy_avail;
143         unsigned int poolsize;
144 };
145
146 struct usr_info {
147         char *names;
148         char *times;
149         char *terms;
150         int number;
151 };
152
153 struct gateway_info {
154         char *iface;
155         char *ip;
156         int count;
157 };
158
159 #ifdef X11
160 struct monitor_info {
161         int number;
162         int current;
163 };
164
165 struct desktop_info {
166         int current;
167         int number;
168         unsigned int nitems;
169         char *all_names;
170         char *name;
171 };
172
173 struct x11_info {
174         struct monitor_info monitor;
175         struct desktop_info desktop;
176 };
177
178 int get_stippled_borders(void);
179
180 #endif /* X11 */
181
182 /* defined in conky.c */
183 extern long default_fg_color, default_bg_color, default_out_color;
184 extern long color0, color1, color2, color3, color4, color5, color6, color7,
185            color8, color9;
186 void set_current_text_color(long colour);
187 long get_current_text_color(void);
188
189 void set_updatereset(int);
190 int get_updatereset(void);
191
192 struct conftree {
193         char* string;
194         struct conftree* horz_next;
195         struct conftree* vert_next;
196         struct conftree* back;
197 };
198
199 char load_config_file(const char *);
200
201 char *get_global_text(void);
202 extern long global_text_lines;
203
204 //adds newstring to to the tree unless you can already see it when travelling back.
205 //if it's possible to attach it then it returns a pointer to the leaf, else it returns NULL
206 struct conftree* conftree_add(struct conftree* previous, const char* newstring);
207
208 extern struct conftree *currentconffile;
209
210 #define MAX_TEMPLATES 10
211 char **get_templates(void);
212
213 enum {
214         INFO_CPU = 0,
215         INFO_MAIL = 1,
216         INFO_MEM = 2,
217         INFO_NET = 3,
218         INFO_PROCS = 4,
219         INFO_RUN_PROCS = 5,
220         INFO_UPTIME = 6,
221         INFO_BUFFERS = 7,
222         INFO_FS = 8,
223         INFO_SYSFS = 9,
224         INFO_MIXER = 10,
225         INFO_LOADAVG = 11,
226         INFO_UNAME = 12,
227         INFO_FREQ = 13,
228 #ifdef MPD
229         INFO_MPD = 14,
230 #endif
231         INFO_TOP = 15,
232         INFO_WIFI = 16,
233         INFO_DISKIO = 17,
234         INFO_I8K = 18,
235 #ifdef TCP_PORT_MONITOR
236         INFO_TCP_PORT_MONITOR = 19,
237 #endif
238 #ifdef AUDACIOUS
239         INFO_AUDACIOUS = 20,
240 #endif
241 #ifdef BMPX
242         INFO_BMPX = 21,
243 #endif
244 #ifdef XMMS2
245         INFO_XMMS2 = 22,
246 #endif
247         INFO_ENTROPY = 23,
248 #ifdef IBM
249         INFO_SMAPI = 25,
250 #endif
251         INFO_USERS = 26,
252         INFO_GW = 27,
253 #ifdef NVIDIA
254         INFO_NVIDIA = 28,
255 #endif
256 #ifdef X11
257         INFO_X11 = 29,
258 #endif
259         INFO_DNS = 30,
260 #ifdef MOC
261         INFO_MOC = 31,
262 #endif
263 #ifdef APCUPSD
264         INFO_APCUPSD = 32,
265 #endif
266 #ifdef WEATHER
267         INFO_WEATHER = 33,
268 #endif
269 };
270
271 /* get_battery_stuff() item selector
272  * needed by conky.c, linux.c and freebsd.c */
273 enum {
274         BATTERY_STATUS,
275         BATTERY_TIME
276 };
277
278 /* if_up strictness selector
279  * needed by conky.c and linux.c (and potentially others) */
280 enum {
281         IFUP_UP,
282         IFUP_LINK,
283         IFUP_ADDR
284 } ifup_strictness;
285
286 struct information {
287         unsigned int mask;
288
289         struct utsname uname_s;
290
291         char freq[10];
292
293         double uptime;
294
295         /* memory information in kilobytes */
296         unsigned long long mem, memeasyfree, memfree, memmax, swap, swapfree, swapmax;
297         unsigned long long bufmem, buffers, cached;
298
299         unsigned short procs;
300         unsigned short run_procs;
301
302         float *cpu_usage;
303         /* struct cpu_stat cpu_summed; what the hell is this? */
304         unsigned int cpu_count;
305         int cpu_avg_samples;
306
307         int net_avg_samples;
308
309         int diskio_avg_samples;
310
311         float loadavg[3];
312
313         struct mail_s *mail;
314         int mail_running;
315 #ifdef XMMS2
316         struct xmms2_s xmms2;
317 #endif
318 #ifdef AUDACIOUS
319         AUDACIOUS_S audacious;
320 #endif
321 #ifdef BMPX
322         struct bmpx_s bmpx;
323 #endif
324         struct usr_info users;
325         struct gateway_info gw_info;
326         struct dns_data nameserver_info;
327         struct process *cpu[10];
328         struct process *memu[10];
329         struct process *time[10];
330 #ifdef IOSTATS
331         struct process *io[10];
332 #endif
333         struct process *first_process;
334         unsigned long looped;
335         struct entropy_s entropy;
336         double music_player_interval;
337
338 #ifdef X11
339         struct x11_info x11;
340 #endif
341
342 #ifdef APCUPSD
343         APCUPSD_S apcupsd;
344 #endif
345
346         short kflags;   /* kernel settings, see enum KFLAG */
347 };
348
349 #ifdef HAVE_LUA
350 #include "llua.h"
351 #endif /* HAVE_LUA */
352
353 /* needed by linux.c and top.c -> outsource somewhere */
354 enum {
355         /* set to true if kernel uses "long" format for /proc/stats */
356         KFLAG_IS_LONGSTAT = 0x01,
357         /* set to true if kernel shows # of threads for the proc value
358          * in sysinfo() call */
359         KFLAG_PROC_IS_THREADS = 0x02
360         /* bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
361         /* KFLAG_NEXT_ONE = 0x04 */
362 };
363 #define KFLAG_SETON(a) info.kflags |= a
364 #define KFLAG_SETOFF(a) info.kflags &= (~a)
365 #define KFLAG_FLIP(a) info.kflags ^= a
366 #define KFLAG_ISSET(a) info.kflags & a
367
368 /* defined in conky.c, needed by top.c */
369 extern int top_cpu, top_mem, top_time;
370 #ifdef IOSTATS
371 extern int top_io;
372 #endif
373
374 /* defined in conky.c, needed by top.c */
375 extern int cpu_separate;
376
377 /* struct that has all info to be shared between
378  * instances of the same text object */
379 extern struct information info;
380
381 /* defined in users.c */
382 void update_users(void);
383
384 /* defined in conky.c */
385 extern double current_update_time, last_update_time, update_interval;
386
387 /* defined in conky.c */
388 int spaced_print(char *, int, const char *, int, ...)
389         __attribute__((format(printf, 3, 5)));
390 extern int inotify_fd;
391
392 /* defined in conky.c
393  * evaluates 'text' and places the result in 'buffer'
394  */
395 void evaluate(const char *text, char *buffer);
396
397 /* maximum size of config TEXT buffer, i.e. below TEXT line. */
398 extern unsigned int max_user_text;
399
400 /* path to config file */
401 extern char *current_config;
402
403 /* just a wrapper for read_exec() defined in conky.c */
404 void do_read_exec(const char *data, char *buf, const int size);
405
406 #ifdef X11
407 #define TO_X 1
408 #endif /* X11 */
409 #define TO_STDOUT 2
410 #define TO_STDERR 4
411 #define OVERWRITE_FILE 8
412 #define APPEND_FILE 16
413 #ifdef NCURSES
414 #define TO_NCURSES 32
415 #endif /* NCURSES */
416 enum x_initialiser_state {
417         NO = 0,
418         YES = 1,
419         NEVER = 2
420 };
421 extern int output_methods;
422 extern enum x_initialiser_state x_initialised;
423
424 void set_update_interval(double interval);
425
426 #define DEFAULT_TEXT_BUFFER_SIZE_S "##DEFAULT_TEXT_BUFFER_SIZE"
427
428 #define NOBATTERY 0
429
430 /* to get rid of 'unused variable' warnings */
431 #define UNUSED(a)  (void)a
432 #define UNUSED_ATTR __attribute__ ((unused))
433
434 #endif /* _conky_h_ */