here comes the big header include rewrite
[monky] / src / text_object.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 #ifndef _TEXT_OBJECT_H
28 #define _TEXT_OBJECT_H
29
30 #include "config.h"             /* for the defines */
31 #include "timed_thread.h"       /* timed_thread */
32
33 #ifdef TCP_PORT_MONITOR
34 #include "tcp-portmon.h"        /* tcp_port_monitor_data */
35 #endif
36
37 #include "mail.h"               /* local_mail_s */
38 #include "fs.h"                 /* struct fs_stat */
39
40 #ifdef NVIDIA
41 #include "nvidia.h"             /* nvidia_s */
42 #endif
43
44 enum text_object_type {
45         OBJ_addr,
46 #if defined(__linux__)
47         OBJ_addrs,
48 #endif /* __linux__ */
49 #ifndef __OpenBSD__
50         OBJ_acpiacadapter,
51         OBJ_adt746xcpu,
52         OBJ_adt746xfan,
53         OBJ_acpifan,
54         OBJ_acpitemp,
55         OBJ_battery,
56         OBJ_battery_time,
57         OBJ_battery_percent,
58         OBJ_battery_bar,
59 #endif /* !__OpenBSD__ */
60         OBJ_buffers,
61         OBJ_cached,
62         OBJ_color,
63         OBJ_color0,
64         OBJ_color1,
65         OBJ_color2,
66         OBJ_color3,
67         OBJ_color4,
68         OBJ_color5,
69         OBJ_color6,
70         OBJ_color7,
71         OBJ_color8,
72         OBJ_color9,
73         OBJ_conky_version,
74         OBJ_conky_build_date,
75         OBJ_conky_build_arch,
76         OBJ_font,
77         OBJ_cpu,
78         OBJ_cpubar,
79         OBJ_cpugraph,
80         OBJ_loadgraph,
81         OBJ_diskio,
82         OBJ_diskio_read,
83         OBJ_diskio_write,
84         OBJ_diskiograph,
85         OBJ_diskiograph_read,
86         OBJ_diskiograph_write,
87         OBJ_downspeed,
88         OBJ_downspeedf,
89         OBJ_downspeedgraph,
90         OBJ_else,
91         OBJ_endif,
92         OBJ_image,
93         OBJ_exec,
94         OBJ_execi,
95         OBJ_texeci,
96         OBJ_execbar,
97         OBJ_execgraph,
98         OBJ_execibar,
99         OBJ_execigraph,
100         OBJ_execp,
101         OBJ_execpi,
102         OBJ_freq,
103         OBJ_freq_g,
104         OBJ_fs_bar,
105         OBJ_fs_bar_free,
106         OBJ_fs_free,
107         OBJ_fs_free_perc,
108         OBJ_fs_size,
109         OBJ_fs_type,
110         OBJ_fs_used,
111         OBJ_fs_used_perc,
112         OBJ_goto,
113         OBJ_tab,
114         OBJ_hr,
115         OBJ_offset,
116         OBJ_voffset,
117         OBJ_alignr,
118         OBJ_alignc,
119         OBJ_i2c,
120         OBJ_platform,
121         OBJ_hwmon,
122 #if defined(__linux__)
123         OBJ_disk_protect,
124         OBJ_i8k_version,
125         OBJ_i8k_bios,
126         OBJ_i8k_serial,
127         OBJ_i8k_cpu_temp,
128         OBJ_i8k_left_fan_status,
129         OBJ_i8k_right_fan_status,
130         OBJ_i8k_left_fan_rpm,
131         OBJ_i8k_right_fan_rpm,
132         OBJ_i8k_ac_status,
133         OBJ_i8k_buttons_status,
134         OBJ_ibm_fan,
135         OBJ_ibm_temps,
136         OBJ_ibm_volume,
137         OBJ_ibm_brightness,
138         OBJ_if_up,
139         OBJ_if_gw,
140         OBJ_ioscheduler,
141         OBJ_gw_iface,
142         OBJ_gw_ip,
143         OBJ_laptop_mode,
144         OBJ_pb_battery,
145         OBJ_voltage_mv,
146         OBJ_voltage_v,
147         OBJ_wireless_essid,
148         OBJ_wireless_mode,
149         OBJ_wireless_bitrate,
150         OBJ_wireless_ap,
151         OBJ_wireless_link_qual,
152         OBJ_wireless_link_qual_max,
153         OBJ_wireless_link_qual_perc,
154         OBJ_wireless_link_bar,
155 #endif /* __linux__ */
156         OBJ_if_empty,
157         OBJ_if_existing,
158         OBJ_if_mounted,
159         OBJ_if_running,
160         OBJ_top,
161         OBJ_top_mem,
162         OBJ_tail,
163         OBJ_head,
164         OBJ_lines,
165         OBJ_words,
166         OBJ_kernel,
167         OBJ_loadavg,
168         OBJ_machine,
169         OBJ_mails,
170         OBJ_mboxscan,
171         OBJ_mem,
172         OBJ_memeasyfree,
173         OBJ_memfree,
174         OBJ_membar,
175         OBJ_memgraph,
176         OBJ_memmax,
177         OBJ_memperc,
178         OBJ_mem_res,
179         OBJ_mem_vsize,
180         OBJ_mixer,
181         OBJ_mixerl,
182         OBJ_mixerr,
183         OBJ_mixerbar,
184         OBJ_mixerlbar,
185         OBJ_mixerrbar,
186 #ifdef X11
187         OBJ_monitor,
188         OBJ_monitor_number,
189 #endif
190         OBJ_nameserver,
191         OBJ_new_mails,
192         OBJ_nodename,
193         OBJ_nvidia,
194         OBJ_pre_exec,
195         OBJ_processes,
196         OBJ_running_processes,
197         OBJ_shadecolor,
198         OBJ_outlinecolor,
199         OBJ_stippled_hr,
200         OBJ_swap,
201         OBJ_swapbar,
202         OBJ_swapmax,
203         OBJ_swapperc,
204         OBJ_sysname,
205         OBJ_temp1,      /* i2c is used instead in these */
206         OBJ_temp2,
207         OBJ_text,
208         OBJ_time,
209         OBJ_utime,
210         OBJ_tztime,
211         OBJ_totaldown,
212         OBJ_totalup,
213         OBJ_updates,
214         OBJ_upspeed,
215         OBJ_upspeedf,
216         OBJ_upspeedgraph,
217         OBJ_uptime,
218         OBJ_uptime_short,
219         OBJ_user_names,
220         OBJ_user_terms,
221         OBJ_user_times,
222         OBJ_user_number,
223         OBJ_imap,
224         OBJ_imap_messages,
225         OBJ_imap_unseen,
226         OBJ_pop3,
227         OBJ_pop3_unseen,
228         OBJ_pop3_used,
229 #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
230                 || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
231         OBJ_apm_adapter,
232         OBJ_apm_battery_time,
233         OBJ_apm_battery_life,
234 #endif /* __FreeBSD__ __OpenBSD__ */
235 #ifdef __OpenBSD__
236         OBJ_obsd_sensors_temp,
237         OBJ_obsd_sensors_fan,
238         OBJ_obsd_sensors_volt,
239         OBJ_obsd_vendor,
240         OBJ_obsd_product,
241 #endif /* __OpenBSD__ */
242 #ifdef MPD
243         OBJ_mpd_title,
244         OBJ_mpd_artist,
245         OBJ_mpd_album,
246         OBJ_mpd_random,
247         OBJ_mpd_repeat,
248         OBJ_mpd_vol,
249         OBJ_mpd_bitrate,
250         OBJ_mpd_status,
251         OBJ_mpd_host,
252         OBJ_mpd_port,
253         OBJ_mpd_password,
254         OBJ_mpd_bar,
255         OBJ_mpd_elapsed,
256         OBJ_mpd_length,
257         OBJ_mpd_track,
258         OBJ_mpd_name,
259         OBJ_mpd_file,
260         OBJ_mpd_percent,
261         OBJ_mpd_smart,
262         OBJ_if_mpd_playing,
263 #endif
264 #ifdef MOC
265         OBJ_moc_state,
266         OBJ_moc_file,
267         OBJ_moc_title,
268         OBJ_moc_artist,
269         OBJ_moc_song,
270         OBJ_moc_album,
271         OBJ_moc_totaltime,
272         OBJ_moc_timeleft,
273         OBJ_moc_curtime,
274         OBJ_moc_bitrate,
275         OBJ_moc_rate,
276 #endif
277         OBJ_music_player_interval,
278 #ifdef XMMS2
279         OBJ_xmms2_artist,
280         OBJ_xmms2_album,
281         OBJ_xmms2_title,
282         OBJ_xmms2_genre,
283         OBJ_xmms2_comment,
284         OBJ_xmms2_url,
285         OBJ_xmms2_date,
286         OBJ_xmms2_tracknr,
287         OBJ_xmms2_bitrate,
288         OBJ_xmms2_id,
289         OBJ_xmms2_duration,
290         OBJ_xmms2_elapsed,
291         OBJ_xmms2_size,
292         OBJ_xmms2_percent,
293         OBJ_xmms2_status,
294         OBJ_xmms2_bar,
295         OBJ_xmms2_smart,
296         OBJ_xmms2_playlist,
297         OBJ_xmms2_timesplayed,
298         OBJ_if_xmms2_connected,
299 #endif
300 #ifdef AUDACIOUS
301         OBJ_audacious_status,
302         OBJ_audacious_title,
303         OBJ_audacious_length,
304         OBJ_audacious_length_seconds,
305         OBJ_audacious_position,
306         OBJ_audacious_position_seconds,
307         OBJ_audacious_bitrate,
308         OBJ_audacious_frequency,
309         OBJ_audacious_channels,
310         OBJ_audacious_filename,
311         OBJ_audacious_playlist_length,
312         OBJ_audacious_playlist_position,
313         OBJ_audacious_main_volume,
314         OBJ_audacious_bar,
315 #endif
316 #ifdef BMPX
317         OBJ_bmpx_title,
318         OBJ_bmpx_artist,
319         OBJ_bmpx_album,
320         OBJ_bmpx_track,
321         OBJ_bmpx_uri,
322         OBJ_bmpx_bitrate,
323 #endif
324 #ifdef EVE
325         OBJ_eve,
326 #endif
327 #ifdef RSS
328         OBJ_rss,
329 #endif
330 #ifdef TCP_PORT_MONITOR
331         OBJ_tcp_portmon,
332 #endif
333 #ifdef HAVE_ICONV
334         OBJ_iconv_start,
335         OBJ_iconv_stop,
336 #endif
337 #ifdef HDDTEMP
338         OBJ_hddtemp,
339 #endif
340 #ifdef SMAPI
341         OBJ_smapi,
342         OBJ_smapi_bat_bar,
343         OBJ_smapi_bat_perc,
344         OBJ_smapi_bat_temp,
345         OBJ_smapi_bat_power,
346         OBJ_if_smapi_bat_installed,
347 #endif
348         OBJ_scroll,
349         OBJ_entropy_avail,
350         OBJ_entropy_poolsize,
351         OBJ_entropy_bar
352 };
353
354 struct text_object {
355         struct text_object *next, *prev;        /* doubly linked list of text objects */
356         union {
357                 char *s;                /* some string */
358                 int i;                  /* some integer */
359                 long l;                 /* some other integer */
360                 unsigned int sensor;
361                 struct net_stat *net;
362                 struct fs_stat *fs;
363                 struct diskio_stat *diskio;
364                 unsigned char loadavg[3];
365                 unsigned int cpu_index;
366                 struct mail_s *mail;
367
368                 struct {
369                         char *args;
370                         char *output;
371                 } mboxscan;
372
373                 struct {
374                         char *tz;       /* timezone variable */
375                         char *fmt;      /* time display formatting */
376                 } tztime;
377
378                 struct {
379                         struct fs_stat *fs;
380                         int w, h;
381                 } fsbar;                /* 3 */
382
383                 struct {
384                         int l;
385                         int w, h;
386                 } mixerbar;             /* 3 */
387
388                 struct {
389                         int fd;
390                         int arg;
391                         char devtype[256];
392                         char type[64];
393                 } sysfs;                /* 2 */
394
395                 struct {
396                         struct text_object *next;
397                         char *s;
398                         char *str;
399                 } ifblock;
400
401                 struct {
402                         int num;
403                         int type;
404                 } top;
405
406                 struct {
407                         int wantedlines;
408                         int readlines;
409                         char *logfile;
410                         double last_update;
411                         float interval;
412                         char *buffer;
413                         /* If not -1, a file descriptor to read from when
414                          * logfile is a FIFO. */
415                         int fd;
416                 } tail;
417
418                 struct {
419                         double last_update;
420                         float interval;
421                         char *cmd;
422                         char *buffer;
423                         double data;
424                 } execi;                /* 5 */
425
426                 struct {
427                         float interval;
428                         char *cmd;
429                         char *buffer;
430                         double data;
431                         timed_thread *p_timed_thread;
432                 } texeci;
433
434                 struct {
435                         int a, b;
436                 } pair;                 /* 2 */
437 #ifdef TCP_PORT_MONITOR
438                 struct tcp_port_monitor_data tcp_port_monitor;
439 #endif
440 #ifdef HDDTEMP
441                 struct {
442                         char *addr;
443                         int port;
444                         char *dev;
445                         double update_time;
446                         char *temp;
447                 } hddtemp;              /* 2 */
448 #endif
449 #ifdef EVE
450                 struct {
451                         char *apikey;
452                         char *charid;
453                         char *userid;
454                 } eve;
455 #endif
456 #ifdef RSS
457                 struct {
458                         char *uri;
459                         char *action;
460                         int act_par;
461                         int delay;
462                 } rss;
463 #endif
464                 struct {
465                         char *text;
466                         unsigned int show;
467                         unsigned int step;
468                         unsigned int start;
469                 } scroll;
470
471                 struct local_mail_s local_mail;
472 #ifdef NVIDIA
473                 struct nvidia_s nvidia;
474 #endif /* NVIDIA */
475
476         } data;
477         int type;
478         int a, b;
479         long line;
480         unsigned int c, d, e;
481         float f;
482         char showaslog;
483         char global_mode;
484 };
485
486 /* text object list helpers */
487 int append_object(struct text_object *root, struct text_object *obj);
488
489 /* ifblock helpers */
490 int obj_be_ifblock_if(struct text_object *);
491 int obj_be_ifblock_else(struct text_object *);
492 int obj_be_ifblock_endif(struct text_object *);
493 int ifblock_stack_empty(void);
494
495 #endif /* _TEXT_OBJECT_H */