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