fs_*: convert to generic object payload
[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 HAVE_CURL
94 #include "ccurl_thread.h"
95 #endif /* HAVE_CURL */
96
97 #ifdef RSS
98 #include "rss.h"
99 #endif /* RSS */
100
101 #ifdef XOAP
102 #ifndef WEATHER
103 #error "WEATHER needs to be defined if XOAP is defined"
104 #endif /* WEATHER */
105 #endif /* XOAP */
106
107 #ifdef WEATHER
108 #include "weather.h"
109 #endif /* WEATHER */
110
111 #ifdef TCP_PORT_MONITOR
112 #include "tcp-portmon.h"
113 #endif
114
115 #ifdef XMMS2
116 #include "xmms2.h"
117 #endif
118
119 #ifdef IBM
120 #include "ibm.h"
121 #include "smapi.h"
122 #endif
123
124 #ifdef APCUPSD
125 #include "apcupsd.h"
126 #endif
127
128 /* sony support */
129 #include "sony.h"
130
131 /* A size for temporary, static buffers to use when
132  * one doesn't know what to choose. Defaults to 256.  */
133 extern unsigned int text_buffer_size;
134
135 struct entropy_s {
136         unsigned int entropy_avail;
137         unsigned int poolsize;
138 };
139
140 struct usr_info {
141         char *names;
142         char *times;
143         char *terms;
144         int number;
145 };
146
147 #ifdef X11
148 struct monitor_info {
149         int number;
150         int current;
151 };
152
153 struct desktop_info {
154         int current;
155         int number;
156         unsigned int nitems;
157         char *all_names;
158         char *name;
159 };
160
161 struct x11_info {
162         struct monitor_info monitor;
163         struct desktop_info desktop;
164 };
165
166 int get_stippled_borders(void);
167
168 #endif /* X11 */
169
170 /* defined in conky.c */
171 extern long default_fg_color, default_bg_color, default_out_color;
172 extern long color0, color1, color2, color3, color4, color5, color6, color7,
173            color8, color9;
174 void set_current_text_color(long colour);
175 long get_current_text_color(void);
176
177 void set_updatereset(int);
178 int get_updatereset(void);
179
180 int percent_print(char *, int, unsigned);
181 void human_readable(long long, char *, int);
182
183 struct conftree {
184         char* string;
185         struct conftree* horz_next;
186         struct conftree* vert_next;
187         struct conftree* back;
188 };
189
190 char load_config_file(const char *);
191
192 char *get_global_text(void);
193 extern long global_text_lines;
194
195 //adds newstring to to the tree unless you can already see it when travelling back.
196 //if it's possible to attach it then it returns a pointer to the leaf, else it returns NULL
197 struct conftree* conftree_add(struct conftree* previous, const char* newstring);
198
199 extern struct conftree *currentconffile;
200
201 #define MAX_TEMPLATES 10
202 char **get_templates(void);
203
204 /* get_battery_stuff() item selector
205  * needed by conky.c, linux.c and freebsd.c */
206 enum {
207         BATTERY_STATUS,
208         BATTERY_TIME
209 };
210
211 /* if_up strictness selector
212  * needed by conky.c and linux.c (and potentially others) */
213 enum {
214         IFUP_UP,
215         IFUP_LINK,
216         IFUP_ADDR
217 } ifup_strictness;
218
219 struct information {
220         unsigned int mask;
221
222         struct utsname uname_s;
223
224         char freq[10];
225
226         double uptime;
227
228         /* memory information in kilobytes */
229         unsigned long long mem, memeasyfree, memfree, memmax, swap, swapfree, swapmax;
230         unsigned long long bufmem, buffers, cached;
231
232         unsigned short procs;
233         unsigned short run_procs;
234
235         float *cpu_usage;
236         /* struct cpu_stat cpu_summed; what the hell is this? */
237         unsigned int cpu_count;
238         int cpu_avg_samples;
239
240         int net_avg_samples;
241
242         int diskio_avg_samples;
243
244         float loadavg[3];
245
246         struct mail_s *mail;
247         int mail_running;
248 #ifdef XMMS2
249         struct xmms2_s xmms2;
250 #endif
251 #ifdef AUDACIOUS
252         AUDACIOUS_S audacious;
253 #endif
254 #ifdef BMPX
255         struct bmpx_s bmpx;
256 #endif
257         struct usr_info users;
258         struct process *cpu[10];
259         struct process *memu[10];
260         struct process *time[10];
261 #ifdef IOSTATS
262         struct process *io[10];
263 #endif
264         struct process *first_process;
265         unsigned long looped;
266         struct entropy_s entropy;
267         double music_player_interval;
268
269 #ifdef X11
270         struct x11_info x11;
271 #endif
272
273 #ifdef APCUPSD
274         APCUPSD_S apcupsd;
275 #endif
276
277         short kflags;   /* kernel settings, see enum KFLAG */
278 };
279
280 #ifdef HAVE_LUA
281 #include "llua.h"
282 #endif /* HAVE_LUA */
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 #ifdef IOSTATS
302 extern int top_io;
303 #endif
304 #ifdef __linux__
305 extern int top_running;
306 #endif
307
308 /* defined in conky.c, needed by top.c */
309 extern int cpu_separate;
310
311 /* struct that has all info to be shared between
312  * instances of the same text object */
313 extern struct information info;
314
315 /* defined in users.c */
316 void update_users(void);
317
318 /* defined in conky.c */
319 extern double current_update_time, last_update_time, update_interval;
320
321 /* defined in conky.c */
322 int spaced_print(char *, int, const char *, int, ...)
323         __attribute__((format(printf, 3, 5)));
324 extern int inotify_fd;
325
326 /* defined in conky.c
327  * evaluates 'text' and places the result in 'buffer'
328  */
329 void evaluate(const char *text, char *buffer);
330
331 /* maximum size of config TEXT buffer, i.e. below TEXT line. */
332 extern unsigned int max_user_text;
333
334 /* path to config file */
335 extern char *current_config;
336
337 #ifdef X11
338 #define TO_X 1
339 #endif /* X11 */
340 #define TO_STDOUT 2
341 #define TO_STDERR 4
342 #define OVERWRITE_FILE 8
343 #define APPEND_FILE 16
344 #ifdef NCURSES
345 #define TO_NCURSES 32
346 #endif /* NCURSES */
347 enum x_initialiser_state {
348         NO = 0,
349         YES = 1,
350         NEVER = 2
351 };
352 extern int output_methods;
353 extern enum x_initialiser_state x_initialised;
354
355 void set_update_interval(double interval);
356
357 #define DEFAULT_TEXT_BUFFER_SIZE_S "##DEFAULT_TEXT_BUFFER_SIZE"
358
359 #define NOBATTERY 0
360
361 /* to get rid of 'unused variable' warnings */
362 #define UNUSED(a)  (void)a
363 #define UNUSED_ATTR __attribute__ ((unused))
364
365 void parse_conky_vars(struct text_object *, const char *,
366                         char *, struct information *);
367
368 void generate_text_internal(char *, int, struct text_object,
369                                    struct information *);
370 #endif /* _conky_h_ */