read_tcp werkt maar moet nog stresstesten ondergaan
[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-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 #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_read_tcp,
46         OBJ_addr,
47 #if defined(__linux__)
48         OBJ_addrs,
49 #endif /* __linux__ */
50 #ifndef __OpenBSD__
51         OBJ_acpiacadapter,
52         OBJ_adt746xcpu,
53         OBJ_adt746xfan,
54         OBJ_acpifan,
55         OBJ_acpitemp,
56         OBJ_battery,
57         OBJ_battery_time,
58         OBJ_battery_percent,
59         OBJ_battery_bar,
60         OBJ_battery_short,
61 #endif /* !__OpenBSD__ */
62         OBJ_buffers,
63         OBJ_cached,
64         OBJ_color,
65         OBJ_color0,
66         OBJ_color1,
67         OBJ_color2,
68         OBJ_color3,
69         OBJ_color4,
70         OBJ_color5,
71         OBJ_color6,
72         OBJ_color7,
73         OBJ_color8,
74         OBJ_color9,
75         OBJ_conky_version,
76         OBJ_conky_build_date,
77         OBJ_conky_build_arch,
78         OBJ_font,
79         OBJ_cpu,
80         OBJ_cpubar,
81 #ifdef X11
82         OBJ_cpugauge,
83         OBJ_cpugraph,
84         OBJ_loadgraph,
85 #endif /* X11 */
86         OBJ_diskio,
87         OBJ_diskio_read,
88         OBJ_diskio_write,
89 #ifdef X11
90         OBJ_diskiograph,
91         OBJ_diskiograph_read,
92         OBJ_diskiograph_write,
93 #endif /* X11 */
94         OBJ_downspeed,
95         OBJ_downspeedf,
96 #ifdef X11
97         OBJ_downspeedgraph,
98 #endif /* X11 */
99         OBJ_else,
100         OBJ_endif,
101         OBJ_eval,
102         OBJ_image,
103         OBJ_exec,
104         OBJ_execi,
105         OBJ_texeci,
106         OBJ_execbar,
107         OBJ_execibar,
108 #ifdef X11
109         OBJ_execgauge,
110         OBJ_execgraph,
111         OBJ_execigraph,
112         OBJ_execigauge,
113 #endif /* X11 */
114         OBJ_execp,
115         OBJ_execpi,
116         OBJ_freq,
117         OBJ_freq_g,
118         OBJ_fs_bar,
119         OBJ_fs_bar_free,
120         OBJ_fs_free,
121         OBJ_fs_free_perc,
122         OBJ_fs_size,
123         OBJ_fs_type,
124         OBJ_fs_used,
125         OBJ_fs_used_perc,
126         OBJ_goto,
127         OBJ_tab,
128         OBJ_hr,
129         OBJ_offset,
130         OBJ_voffset,
131         OBJ_alignr,
132         OBJ_alignc,
133         OBJ_i2c,
134         OBJ_platform,
135         OBJ_hwmon,
136 #if defined(__linux__)
137         OBJ_disk_protect,
138         OBJ_i8k_version,
139         OBJ_i8k_bios,
140         OBJ_i8k_serial,
141         OBJ_i8k_cpu_temp,
142         OBJ_i8k_left_fan_status,
143         OBJ_i8k_right_fan_status,
144         OBJ_i8k_left_fan_rpm,
145         OBJ_i8k_right_fan_rpm,
146         OBJ_i8k_ac_status,
147         OBJ_i8k_buttons_status,
148 #if defined(IBM)
149         OBJ_ibm_fan,
150         OBJ_ibm_temps,
151         OBJ_ibm_volume,
152         OBJ_ibm_brightness,
153         OBJ_smapi,
154 #ifdef X11
155         OBJ_smapi_bat_bar,
156 #endif /* X11 */
157         OBJ_smapi_bat_perc,
158         OBJ_smapi_bat_temp,
159         OBJ_smapi_bat_power,
160         OBJ_if_smapi_bat_installed,
161 #endif /* IBM */
162         /* information from sony_laptop kernel module
163          * /sys/devices/platform/sony-laptop */
164         OBJ_sony_fanspeed,
165         OBJ_if_gw,
166         OBJ_ioscheduler,
167         OBJ_gw_iface,
168         OBJ_gw_ip,
169         OBJ_laptop_mode,
170         OBJ_pb_battery,
171         OBJ_voltage_mv,
172         OBJ_voltage_v,
173         OBJ_wireless_essid,
174         OBJ_wireless_mode,
175         OBJ_wireless_bitrate,
176         OBJ_wireless_ap,
177         OBJ_wireless_link_qual,
178         OBJ_wireless_link_qual_max,
179         OBJ_wireless_link_qual_perc,
180 #ifdef X11
181         OBJ_wireless_link_bar,
182 #endif /* X11 */
183 #endif /* __linux__ */
184 #if defined(__FreeBSD__) || defined(__linux__)
185         OBJ_if_up,
186 #endif
187         OBJ_if_empty,
188         OBJ_if_match,
189         OBJ_if_existing,
190         OBJ_if_mounted,
191         OBJ_if_running,
192         OBJ_if_updatenr,
193         OBJ_top,
194         OBJ_top_mem,
195         OBJ_top_time,
196         OBJ_tail,
197         OBJ_head,
198         OBJ_lines,
199         OBJ_words,
200         OBJ_kernel,
201         OBJ_loadavg,
202         OBJ_machine,
203         OBJ_mails,
204         OBJ_new_mails,
205         OBJ_seen_mails,
206         OBJ_unseen_mails,
207         OBJ_flagged_mails,
208         OBJ_unflagged_mails,
209         OBJ_forwarded_mails,
210         OBJ_unforwarded_mails,
211         OBJ_replied_mails,
212         OBJ_unreplied_mails,
213         OBJ_draft_mails,
214         OBJ_trashed_mails,
215         OBJ_mboxscan,
216         OBJ_mem,
217         OBJ_memeasyfree,
218         OBJ_memfree,
219 #ifdef X11
220         OBJ_memgauge,
221         OBJ_memgraph,
222 #endif /* X11 */
223         OBJ_membar,
224         OBJ_memmax,
225         OBJ_memperc,
226         OBJ_mixer,
227         OBJ_mixerl,
228         OBJ_mixerr,
229 #ifdef X11
230         OBJ_mixerbar,
231         OBJ_mixerlbar,
232         OBJ_mixerrbar,
233 #endif /* X11 */
234         OBJ_if_mixer_mute,
235 #ifdef X11
236         OBJ_monitor,
237         OBJ_monitor_number,
238 #endif /* X11 */
239         OBJ_nameserver,
240         OBJ_nodename,
241         OBJ_nvidia,
242         OBJ_pre_exec,
243         OBJ_processes,
244         OBJ_running_processes,
245         OBJ_shadecolor,
246         OBJ_outlinecolor,
247         OBJ_stippled_hr,
248         OBJ_swap,
249         OBJ_swapbar,
250         OBJ_swapmax,
251         OBJ_swapperc,
252         OBJ_sysname,
253         OBJ_text,
254         OBJ_time,
255         OBJ_utime,
256         OBJ_tztime,
257         OBJ_totaldown,
258         OBJ_totalup,
259         OBJ_updates,
260         OBJ_upspeed,
261         OBJ_upspeedf,
262 #ifdef X11
263         OBJ_upspeedgraph,
264 #endif /* X11 */
265         OBJ_uptime,
266         OBJ_uptime_short,
267         OBJ_user_names,
268         OBJ_user_terms,
269         OBJ_user_times,
270         OBJ_user_number,
271         OBJ_imap_messages,
272         OBJ_imap_unseen,
273         OBJ_pop3_unseen,
274         OBJ_pop3_used,
275 #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
276                 || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
277         OBJ_apm_adapter,
278         OBJ_apm_battery_time,
279         OBJ_apm_battery_life,
280 #endif /* __FreeBSD__ __OpenBSD__ */
281 #ifdef __OpenBSD__
282         OBJ_obsd_sensors_temp,
283         OBJ_obsd_sensors_fan,
284         OBJ_obsd_sensors_volt,
285         OBJ_obsd_vendor,
286         OBJ_obsd_product,
287 #endif /* __OpenBSD__ */
288 #ifdef MPD
289         OBJ_mpd_title,
290         OBJ_mpd_artist,
291         OBJ_mpd_album,
292         OBJ_mpd_random,
293         OBJ_mpd_repeat,
294         OBJ_mpd_vol,
295         OBJ_mpd_bitrate,
296         OBJ_mpd_status,
297         OBJ_mpd_bar,
298         OBJ_mpd_elapsed,
299         OBJ_mpd_length,
300         OBJ_mpd_track,
301         OBJ_mpd_name,
302         OBJ_mpd_file,
303         OBJ_mpd_percent,
304         OBJ_mpd_smart,
305         OBJ_if_mpd_playing,
306 #endif /* MPD */
307 #ifdef MOC
308         OBJ_moc_state,
309         OBJ_moc_file,
310         OBJ_moc_title,
311         OBJ_moc_artist,
312         OBJ_moc_song,
313         OBJ_moc_album,
314         OBJ_moc_totaltime,
315         OBJ_moc_timeleft,
316         OBJ_moc_curtime,
317         OBJ_moc_bitrate,
318         OBJ_moc_rate,
319 #endif /* MOC */
320 #ifdef XMMS2
321         OBJ_xmms2_artist,
322         OBJ_xmms2_album,
323         OBJ_xmms2_title,
324         OBJ_xmms2_genre,
325         OBJ_xmms2_comment,
326         OBJ_xmms2_url,
327         OBJ_xmms2_date,
328         OBJ_xmms2_tracknr,
329         OBJ_xmms2_bitrate,
330         OBJ_xmms2_id,
331         OBJ_xmms2_duration,
332         OBJ_xmms2_elapsed,
333         OBJ_xmms2_size,
334         OBJ_xmms2_percent,
335         OBJ_xmms2_status,
336 #ifdef X11
337         OBJ_xmms2_bar,
338 #endif /* X11 */
339         OBJ_xmms2_smart,
340         OBJ_xmms2_playlist,
341         OBJ_xmms2_timesplayed,
342         OBJ_if_xmms2_connected,
343 #endif /* XMMS2 */
344 #ifdef AUDACIOUS
345         OBJ_audacious_status,
346         OBJ_audacious_title,
347         OBJ_audacious_length,
348         OBJ_audacious_length_seconds,
349         OBJ_audacious_position,
350         OBJ_audacious_position_seconds,
351         OBJ_audacious_bitrate,
352         OBJ_audacious_frequency,
353         OBJ_audacious_channels,
354         OBJ_audacious_filename,
355         OBJ_audacious_playlist_length,
356         OBJ_audacious_playlist_position,
357         OBJ_audacious_main_volume,
358 #ifdef X11
359         OBJ_audacious_bar,
360 #endif /* X11 */
361 #endif /* AUDACIOUS */
362 #ifdef BMPX
363         OBJ_bmpx_title,
364         OBJ_bmpx_artist,
365         OBJ_bmpx_album,
366         OBJ_bmpx_track,
367         OBJ_bmpx_uri,
368         OBJ_bmpx_bitrate,
369 #endif /* BMPX */
370 #ifdef EVE
371         OBJ_eve,
372 #endif /* EVE */
373 #ifdef RSS
374         OBJ_rss,
375 #endif /* RSS */
376 #ifdef HAVE_LUA
377         OBJ_lua,
378         OBJ_lua_parse,
379         OBJ_lua_read_parse,
380         OBJ_lua_bar,
381 #ifdef X11
382         OBJ_lua_graph,
383         OBJ_lua_gauge,
384 #endif /* X11 */
385 #endif /* HAVE_LUA */
386 #ifdef TCP_PORT_MONITOR
387         OBJ_tcp_portmon,
388 #endif /* TCP_PORT_MONITOR */
389 #ifdef HAVE_ICONV
390         OBJ_iconv_start,
391         OBJ_iconv_stop,
392 #endif /* HAVE_ICONV */
393 #ifdef HDDTEMP
394         OBJ_hddtemp,
395 #endif /* HDDTEMP */
396         OBJ_scroll,
397         OBJ_combine,
398         OBJ_entropy_avail,
399         OBJ_entropy_poolsize,
400         OBJ_entropy_bar,
401 #ifdef APCUPSD
402         OBJ_apcupsd,
403         OBJ_apcupsd_name,
404         OBJ_apcupsd_model,
405         OBJ_apcupsd_upsmode,
406         OBJ_apcupsd_cable,
407         OBJ_apcupsd_status,
408         OBJ_apcupsd_linev,
409         OBJ_apcupsd_load,
410         OBJ_apcupsd_loadbar,
411 #ifdef X11
412         OBJ_apcupsd_loadgraph,
413         OBJ_apcupsd_loadgauge,
414 #endif /* X11 */
415         OBJ_apcupsd_charge,
416         OBJ_apcupsd_timeleft,
417         OBJ_apcupsd_temp,
418         OBJ_apcupsd_lastxfer,
419 #endif /* APCUPSD */
420 };
421
422 struct text_object {
423         struct text_object *next, *prev;        /* doubly linked list of text objects */
424         struct text_object *sub;                /* for objects parsing text into objects */
425         union {
426                 char *s;                /* some string */
427                 int i;                  /* some integer */
428                 long l;                 /* some other integer */
429                 unsigned int sensor;
430                 struct net_stat *net;
431                 struct fs_stat *fs;
432                 struct diskio_stat *diskio;
433                 unsigned char loadavg[3];
434                 unsigned int cpu_index;
435                 struct mail_s *mail;
436
437                 struct {
438                         char *args;
439                         char *output;
440                 } mboxscan;
441
442                 struct {
443                         char *tz;       /* timezone variable */
444                         char *fmt;      /* time display formatting */
445                 } tztime;
446
447                 struct {
448                         struct fs_stat *fs;
449                         int w, h;
450                 } fsbar;                /* 3 */
451
452 #ifdef X11
453                 struct {
454                         int l;
455                         int w, h;
456                 } mixerbar;             /* 3 */
457 #endif
458
459                 struct {
460                         int fd;
461                         int arg;
462                         char devtype[256];
463                         char type[64];
464                         float factor, offset;
465                 } sysfs;
466
467                 struct {
468                         struct text_object *next;
469                         char *s;
470                         int i;
471                         char *str;
472                 } ifblock;
473
474                 struct {
475                         int num;
476                         int type;
477                         int was_parsed;
478                         char *s;
479                 } top;
480
481                 struct {
482                         int wantedlines;
483                         int readlines;
484                         char *logfile;
485                         double last_update;
486                         float interval;
487                         char *buffer;
488                         /* If not -1, a file descriptor to read from when
489                          * logfile is a FIFO. */
490                         int fd;
491                 } tail;
492
493                 struct {
494                         double last_update;
495                         float interval;
496                         char *cmd;
497                         char *buffer;
498                         double data;
499                 } execi;                /* 5 */
500
501                 struct {
502                         float interval;
503                         char *cmd;
504                         char *buffer;
505                         double data;
506                         timed_thread *p_timed_thread;
507                 } texeci;
508
509                 struct {
510                         int a, b;
511                 } pair;                 /* 2 */
512 #ifdef TCP_PORT_MONITOR
513                 struct tcp_port_monitor_data tcp_port_monitor;
514 #endif
515 #ifdef HDDTEMP
516                 struct {
517                         char *addr;
518                         int port;
519                         char *dev;
520                         double update_time;
521                         char *temp;
522                 } hddtemp;              /* 2 */
523 #endif
524 #ifdef EVE
525                 struct {
526                         char *apikey;
527                         char *charid;
528                         char *userid;
529                 } eve;
530 #endif
531 #ifdef RSS
532                 struct {
533                         char *uri;
534                         char *action;
535                         int act_par;
536                         int delay;
537                         unsigned int nrspaces;
538                 } rss;
539 #endif
540                 struct {
541                         char *text;
542                         unsigned int show;
543                         unsigned int step;
544                         unsigned int start;
545                 } scroll;
546
547                 struct {
548                         char *left;
549                         char *seperation;
550                         char *right;
551                 } combine;
552
553                 struct {
554                         char *host;
555                         unsigned int port;
556                 } read_tcp;
557
558                 struct local_mail_s local_mail;
559 #ifdef NVIDIA
560                 struct nvidia_s nvidia;
561 #endif /* NVIDIA */
562
563         } data;
564         int type;
565         int a, b;
566         long line;
567         unsigned int c, d, e;
568         float f;
569         char char_a, char_b;
570 };
571
572 /* text object list helpers */
573 int append_object(struct text_object *root, struct text_object *obj);
574
575 /* ifblock helpers
576  *
577  * Opaque is a pointer to the address of the ifblock stack's top object.
578  * Calling clients should pass the address of a defined void pointer which
579  * was initialised to NULL (empty stack).
580  * */
581 int obj_be_ifblock_if(void **opaque, struct text_object *);
582 int obj_be_ifblock_else(void **opaque, struct text_object *);
583 int obj_be_ifblock_endif(void **opaque, struct text_object *);
584 int ifblock_stack_empty(void **opaque);
585
586 #endif /* _TEXT_OBJECT_H */