add if_match object comparing strings, floats and ints
[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_match,
158         OBJ_if_existing,
159         OBJ_if_mounted,
160         OBJ_if_running,
161         OBJ_top,
162         OBJ_top_mem,
163         OBJ_tail,
164         OBJ_head,
165         OBJ_lines,
166         OBJ_words,
167         OBJ_kernel,
168         OBJ_loadavg,
169         OBJ_machine,
170         OBJ_mails,
171         OBJ_mboxscan,
172         OBJ_mem,
173         OBJ_memeasyfree,
174         OBJ_memfree,
175         OBJ_membar,
176         OBJ_memgraph,
177         OBJ_memmax,
178         OBJ_memperc,
179         OBJ_mem_res,
180         OBJ_mem_vsize,
181         OBJ_mixer,
182         OBJ_mixerl,
183         OBJ_mixerr,
184         OBJ_mixerbar,
185         OBJ_mixerlbar,
186         OBJ_mixerrbar,
187 #ifdef X11
188         OBJ_monitor,
189         OBJ_monitor_number,
190 #endif
191         OBJ_nameserver,
192         OBJ_new_mails,
193         OBJ_nodename,
194         OBJ_nvidia,
195         OBJ_pre_exec,
196         OBJ_processes,
197         OBJ_running_processes,
198         OBJ_shadecolor,
199         OBJ_outlinecolor,
200         OBJ_stippled_hr,
201         OBJ_swap,
202         OBJ_swapbar,
203         OBJ_swapmax,
204         OBJ_swapperc,
205         OBJ_sysname,
206         OBJ_temp1,      /* i2c is used instead in these */
207         OBJ_temp2,
208         OBJ_text,
209         OBJ_time,
210         OBJ_utime,
211         OBJ_tztime,
212         OBJ_totaldown,
213         OBJ_totalup,
214         OBJ_updates,
215         OBJ_upspeed,
216         OBJ_upspeedf,
217         OBJ_upspeedgraph,
218         OBJ_uptime,
219         OBJ_uptime_short,
220         OBJ_user_names,
221         OBJ_user_terms,
222         OBJ_user_times,
223         OBJ_user_number,
224         OBJ_imap,
225         OBJ_imap_messages,
226         OBJ_imap_unseen,
227         OBJ_pop3,
228         OBJ_pop3_unseen,
229         OBJ_pop3_used,
230 #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
231                 || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
232         OBJ_apm_adapter,
233         OBJ_apm_battery_time,
234         OBJ_apm_battery_life,
235 #endif /* __FreeBSD__ __OpenBSD__ */
236 #ifdef __OpenBSD__
237         OBJ_obsd_sensors_temp,
238         OBJ_obsd_sensors_fan,
239         OBJ_obsd_sensors_volt,
240         OBJ_obsd_vendor,
241         OBJ_obsd_product,
242 #endif /* __OpenBSD__ */
243 #ifdef MPD
244         OBJ_mpd_title,
245         OBJ_mpd_artist,
246         OBJ_mpd_album,
247         OBJ_mpd_random,
248         OBJ_mpd_repeat,
249         OBJ_mpd_vol,
250         OBJ_mpd_bitrate,
251         OBJ_mpd_status,
252         OBJ_mpd_host,
253         OBJ_mpd_port,
254         OBJ_mpd_password,
255         OBJ_mpd_bar,
256         OBJ_mpd_elapsed,
257         OBJ_mpd_length,
258         OBJ_mpd_track,
259         OBJ_mpd_name,
260         OBJ_mpd_file,
261         OBJ_mpd_percent,
262         OBJ_mpd_smart,
263         OBJ_if_mpd_playing,
264 #endif
265 #ifdef MOC
266         OBJ_moc_state,
267         OBJ_moc_file,
268         OBJ_moc_title,
269         OBJ_moc_artist,
270         OBJ_moc_song,
271         OBJ_moc_album,
272         OBJ_moc_totaltime,
273         OBJ_moc_timeleft,
274         OBJ_moc_curtime,
275         OBJ_moc_bitrate,
276         OBJ_moc_rate,
277 #endif
278         OBJ_music_player_interval,
279 #ifdef XMMS2
280         OBJ_xmms2_artist,
281         OBJ_xmms2_album,
282         OBJ_xmms2_title,
283         OBJ_xmms2_genre,
284         OBJ_xmms2_comment,
285         OBJ_xmms2_url,
286         OBJ_xmms2_date,
287         OBJ_xmms2_tracknr,
288         OBJ_xmms2_bitrate,
289         OBJ_xmms2_id,
290         OBJ_xmms2_duration,
291         OBJ_xmms2_elapsed,
292         OBJ_xmms2_size,
293         OBJ_xmms2_percent,
294         OBJ_xmms2_status,
295         OBJ_xmms2_bar,
296         OBJ_xmms2_smart,
297         OBJ_xmms2_playlist,
298         OBJ_xmms2_timesplayed,
299         OBJ_if_xmms2_connected,
300 #endif
301 #ifdef AUDACIOUS
302         OBJ_audacious_status,
303         OBJ_audacious_title,
304         OBJ_audacious_length,
305         OBJ_audacious_length_seconds,
306         OBJ_audacious_position,
307         OBJ_audacious_position_seconds,
308         OBJ_audacious_bitrate,
309         OBJ_audacious_frequency,
310         OBJ_audacious_channels,
311         OBJ_audacious_filename,
312         OBJ_audacious_playlist_length,
313         OBJ_audacious_playlist_position,
314         OBJ_audacious_main_volume,
315         OBJ_audacious_bar,
316 #endif
317 #ifdef BMPX
318         OBJ_bmpx_title,
319         OBJ_bmpx_artist,
320         OBJ_bmpx_album,
321         OBJ_bmpx_track,
322         OBJ_bmpx_uri,
323         OBJ_bmpx_bitrate,
324 #endif
325 #ifdef EVE
326         OBJ_eve,
327 #endif
328 #ifdef RSS
329         OBJ_rss,
330 #endif
331 #ifdef TCP_PORT_MONITOR
332         OBJ_tcp_portmon,
333 #endif
334 #ifdef HAVE_ICONV
335         OBJ_iconv_start,
336         OBJ_iconv_stop,
337 #endif
338 #ifdef HDDTEMP
339         OBJ_hddtemp,
340 #endif
341 #ifdef SMAPI
342         OBJ_smapi,
343         OBJ_smapi_bat_bar,
344         OBJ_smapi_bat_perc,
345         OBJ_smapi_bat_temp,
346         OBJ_smapi_bat_power,
347         OBJ_if_smapi_bat_installed,
348 #endif
349         OBJ_scroll,
350         OBJ_entropy_avail,
351         OBJ_entropy_poolsize,
352         OBJ_entropy_bar
353 };
354
355 struct text_object {
356         struct text_object *next, *prev;        /* doubly linked list of text objects */
357         union {
358                 char *s;                /* some string */
359                 int i;                  /* some integer */
360                 long l;                 /* some other integer */
361                 unsigned int sensor;
362                 struct net_stat *net;
363                 struct fs_stat *fs;
364                 struct diskio_stat *diskio;
365                 unsigned char loadavg[3];
366                 unsigned int cpu_index;
367                 struct mail_s *mail;
368
369                 struct {
370                         char *args;
371                         char *output;
372                 } mboxscan;
373
374                 struct {
375                         char *tz;       /* timezone variable */
376                         char *fmt;      /* time display formatting */
377                 } tztime;
378
379                 struct {
380                         struct fs_stat *fs;
381                         int w, h;
382                 } fsbar;                /* 3 */
383
384                 struct {
385                         int l;
386                         int w, h;
387                 } mixerbar;             /* 3 */
388
389                 struct {
390                         int fd;
391                         int arg;
392                         char devtype[256];
393                         char type[64];
394                 } sysfs;                /* 2 */
395
396                 struct {
397                         struct text_object *next;
398                         char *s;
399                         char *str;
400                 } ifblock;
401
402                 struct {
403                         int num;
404                         int type;
405                 } top;
406
407                 struct {
408                         int wantedlines;
409                         int readlines;
410                         char *logfile;
411                         double last_update;
412                         float interval;
413                         char *buffer;
414                         /* If not -1, a file descriptor to read from when
415                          * logfile is a FIFO. */
416                         int fd;
417                 } tail;
418
419                 struct {
420                         double last_update;
421                         float interval;
422                         char *cmd;
423                         char *buffer;
424                         double data;
425                 } execi;                /* 5 */
426
427                 struct {
428                         float interval;
429                         char *cmd;
430                         char *buffer;
431                         double data;
432                         timed_thread *p_timed_thread;
433                 } texeci;
434
435                 struct {
436                         int a, b;
437                 } pair;                 /* 2 */
438 #ifdef TCP_PORT_MONITOR
439                 struct tcp_port_monitor_data tcp_port_monitor;
440 #endif
441 #ifdef HDDTEMP
442                 struct {
443                         char *addr;
444                         int port;
445                         char *dev;
446                         double update_time;
447                         char *temp;
448                 } hddtemp;              /* 2 */
449 #endif
450 #ifdef EVE
451                 struct {
452                         char *apikey;
453                         char *charid;
454                         char *userid;
455                 } eve;
456 #endif
457 #ifdef RSS
458                 struct {
459                         char *uri;
460                         char *action;
461                         int act_par;
462                         int delay;
463                 } rss;
464 #endif
465                 struct {
466                         char *text;
467                         unsigned int show;
468                         unsigned int step;
469                         unsigned int start;
470                 } scroll;
471
472                 struct local_mail_s local_mail;
473 #ifdef NVIDIA
474                 struct nvidia_s nvidia;
475 #endif /* NVIDIA */
476
477         } data;
478         int type;
479         int a, b;
480         long line;
481         unsigned int c, d, e;
482         float f;
483         char showaslog;
484         char global_mode;
485 };
486
487 /* text object list helpers */
488 int append_object(struct text_object *root, struct text_object *obj);
489
490 /* ifblock helpers */
491 int obj_be_ifblock_if(struct text_object *);
492 int obj_be_ifblock_else(struct text_object *);
493 int obj_be_ifblock_endif(struct text_object *);
494 int ifblock_stack_empty(void);
495
496 #endif /* _TEXT_OBJECT_H */