fs_*: convert to generic object payload
[monky] / src / text_object.h
1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
2  *
3  * Conky, a system monitor, based on torsmo
4  *
5  * Any original torsmo code is licensed under the BSD license
6  *
7  * All code written since the fork of torsmo is licensed under the GPL
8  *
9  * Please see COPYING for details
10  *
11  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
12  * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
13  *      (see AUTHORS)
14  * All rights reserved.
15  *
16  * This program is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  * You should have received a copy of the GNU General Public License
26  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
27  *
28  */
29 #ifndef _TEXT_OBJECT_H
30 #define _TEXT_OBJECT_H
31
32 #include "config.h"             /* for the defines */
33 #include "timed_thread.h"       /* timed_thread */
34
35 #ifdef TCP_PORT_MONITOR
36 #include "tcp-portmon.h"        /* tcp_port_monitor_data */
37 #endif
38
39 #include "mail.h"               /* local_mail_s */
40 #include "fs.h"                 /* struct fs_stat */
41
42 enum text_object_type {
43         OBJ_read_tcp,
44         OBJ_addr,
45 #if defined(__linux__)
46         OBJ_addrs,
47 #endif /* __linux__ */
48 #ifndef __OpenBSD__
49         OBJ_acpiacadapter,
50         OBJ_adt746xcpu,
51         OBJ_adt746xfan,
52         OBJ_acpifan,
53         OBJ_acpitemp,
54         OBJ_battery,
55         OBJ_battery_time,
56         OBJ_battery_percent,
57         OBJ_battery_bar,
58         OBJ_battery_short,
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 #ifdef X11
80         OBJ_cpugauge,
81         OBJ_cpugraph,
82         OBJ_loadgraph,
83 #endif /* X11 */
84         OBJ_diskio,
85         OBJ_diskio_read,
86         OBJ_diskio_write,
87 #ifdef X11
88         OBJ_diskiograph,
89         OBJ_diskiograph_read,
90         OBJ_diskiograph_write,
91 #endif /* X11 */
92         OBJ_downspeed,
93         OBJ_downspeedf,
94 #ifdef X11
95         OBJ_downspeedgraph,
96 #endif /* X11 */
97         OBJ_else,
98         OBJ_endif,
99         OBJ_eval,
100         OBJ_image,
101         OBJ_exec,
102         OBJ_execi,
103         OBJ_texeci,
104         OBJ_execbar,
105         OBJ_execibar,
106 #ifdef X11
107         OBJ_execgauge,
108         OBJ_execgraph,
109         OBJ_execigraph,
110         OBJ_execigauge,
111 #endif /* X11 */
112         OBJ_execp,
113         OBJ_execpi,
114         OBJ_freq,
115         OBJ_freq_g,
116         OBJ_fs_bar,
117         OBJ_fs_bar_free,
118         OBJ_fs_free,
119         OBJ_fs_free_perc,
120         OBJ_fs_size,
121         OBJ_fs_type,
122         OBJ_fs_used,
123         OBJ_fs_used_perc,
124         OBJ_goto,
125         OBJ_tab,
126         OBJ_hr,
127         OBJ_offset,
128         OBJ_voffset,
129         OBJ_alignr,
130         OBJ_alignc,
131         OBJ_i2c,
132         OBJ_platform,
133         OBJ_hwmon,
134 #if defined(__linux__)
135         OBJ_disk_protect,
136         OBJ_i8k_version,
137         OBJ_i8k_bios,
138         OBJ_i8k_serial,
139         OBJ_i8k_cpu_temp,
140         OBJ_i8k_left_fan_status,
141         OBJ_i8k_right_fan_status,
142         OBJ_i8k_left_fan_rpm,
143         OBJ_i8k_right_fan_rpm,
144         OBJ_i8k_ac_status,
145         OBJ_i8k_buttons_status,
146 #if defined(IBM)
147         OBJ_ibm_fan,
148         OBJ_ibm_temps,
149         OBJ_ibm_volume,
150         OBJ_ibm_brightness,
151         OBJ_smapi,
152 #ifdef X11
153         OBJ_smapi_bat_bar,
154 #endif /* X11 */
155         OBJ_smapi_bat_perc,
156         OBJ_smapi_bat_temp,
157         OBJ_smapi_bat_power,
158         OBJ_if_smapi_bat_installed,
159 #endif /* IBM */
160         /* information from sony_laptop kernel module
161          * /sys/devices/platform/sony-laptop */
162         OBJ_sony_fanspeed,
163         OBJ_if_gw,
164         OBJ_ioscheduler,
165         OBJ_gw_iface,
166         OBJ_gw_ip,
167         OBJ_laptop_mode,
168         OBJ_pb_battery,
169         OBJ_voltage_mv,
170         OBJ_voltage_v,
171         OBJ_wireless_essid,
172         OBJ_wireless_mode,
173         OBJ_wireless_bitrate,
174         OBJ_wireless_ap,
175         OBJ_wireless_link_qual,
176         OBJ_wireless_link_qual_max,
177         OBJ_wireless_link_qual_perc,
178         OBJ_wireless_link_bar,
179 #endif /* __linux__ */
180 #if defined(__FreeBSD__) || defined(__linux__)
181         OBJ_if_up,
182 #endif
183         OBJ_if_empty,
184         OBJ_if_match,
185         OBJ_if_existing,
186         OBJ_if_mounted,
187         OBJ_if_running,
188         OBJ_if_updatenr,
189         OBJ_top,
190         OBJ_top_mem,
191         OBJ_top_time,
192 #ifdef IOSTATS
193         OBJ_top_io,
194 #endif
195         OBJ_tail,
196         OBJ_head,
197         OBJ_lines,
198         OBJ_words,
199         OBJ_kernel,
200         OBJ_loadavg,
201         OBJ_machine,
202         OBJ_mails,
203         OBJ_new_mails,
204         OBJ_seen_mails,
205         OBJ_unseen_mails,
206         OBJ_flagged_mails,
207         OBJ_unflagged_mails,
208         OBJ_forwarded_mails,
209         OBJ_unforwarded_mails,
210         OBJ_replied_mails,
211         OBJ_unreplied_mails,
212         OBJ_draft_mails,
213         OBJ_trashed_mails,
214         OBJ_mboxscan,
215         OBJ_mem,
216         OBJ_memeasyfree,
217         OBJ_memfree,
218 #ifdef X11
219         OBJ_memgauge,
220         OBJ_memgraph,
221 #endif /* X11 */
222         OBJ_membar,
223         OBJ_memmax,
224         OBJ_memperc,
225         OBJ_mixer,
226         OBJ_mixerl,
227         OBJ_mixerr,
228 #ifdef X11
229         OBJ_mixerbar,
230         OBJ_mixerlbar,
231         OBJ_mixerrbar,
232 #endif /* X11 */
233         OBJ_if_mixer_mute,
234 #ifdef X11
235         OBJ_monitor,
236         OBJ_monitor_number,
237         OBJ_desktop,
238         OBJ_desktop_number,
239         OBJ_desktop_name,
240 #endif /* X11 */
241         OBJ_nameserver,
242         OBJ_nodename,
243         OBJ_nvidia,
244         OBJ_pre_exec,
245         OBJ_processes,
246         OBJ_running_processes,
247         OBJ_shadecolor,
248         OBJ_outlinecolor,
249         OBJ_stippled_hr,
250         OBJ_swap,
251         OBJ_swapfree,
252         OBJ_swapbar,
253         OBJ_swapmax,
254         OBJ_swapperc,
255         OBJ_sysname,
256         OBJ_text,
257         OBJ_time,
258         OBJ_utime,
259         OBJ_tztime,
260         OBJ_totaldown,
261         OBJ_totalup,
262         OBJ_updates,
263         OBJ_upspeed,
264         OBJ_upspeedf,
265 #ifdef X11
266         OBJ_upspeedgraph,
267 #endif /* X11 */
268         OBJ_uptime,
269         OBJ_uptime_short,
270         OBJ_user_names,
271         OBJ_user_terms,
272         OBJ_user_times,
273         OBJ_user_number,
274         OBJ_imap_messages,
275         OBJ_imap_unseen,
276         OBJ_pop3_unseen,
277         OBJ_pop3_used,
278 #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
279                 || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
280         OBJ_apm_adapter,
281         OBJ_apm_battery_time,
282         OBJ_apm_battery_life,
283 #endif /* __FreeBSD__ __OpenBSD__ */
284 #ifdef __OpenBSD__
285         OBJ_obsd_sensors_temp,
286         OBJ_obsd_sensors_fan,
287         OBJ_obsd_sensors_volt,
288         OBJ_obsd_vendor,
289         OBJ_obsd_product,
290 #endif /* __OpenBSD__ */
291 #ifdef MPD
292         OBJ_mpd_title,
293         OBJ_mpd_artist,
294         OBJ_mpd_album,
295         OBJ_mpd_random,
296         OBJ_mpd_repeat,
297         OBJ_mpd_vol,
298         OBJ_mpd_bitrate,
299         OBJ_mpd_status,
300         OBJ_mpd_bar,
301         OBJ_mpd_elapsed,
302         OBJ_mpd_length,
303         OBJ_mpd_track,
304         OBJ_mpd_name,
305         OBJ_mpd_file,
306         OBJ_mpd_percent,
307         OBJ_mpd_smart,
308         OBJ_if_mpd_playing,
309 #endif /* MPD */
310 #ifdef MOC
311         OBJ_moc_state,
312         OBJ_moc_file,
313         OBJ_moc_title,
314         OBJ_moc_artist,
315         OBJ_moc_song,
316         OBJ_moc_album,
317         OBJ_moc_totaltime,
318         OBJ_moc_timeleft,
319         OBJ_moc_curtime,
320         OBJ_moc_bitrate,
321         OBJ_moc_rate,
322 #endif /* MOC */
323 #ifdef XMMS2
324         OBJ_xmms2_artist,
325         OBJ_xmms2_album,
326         OBJ_xmms2_title,
327         OBJ_xmms2_genre,
328         OBJ_xmms2_comment,
329         OBJ_xmms2_url,
330         OBJ_xmms2_date,
331         OBJ_xmms2_tracknr,
332         OBJ_xmms2_bitrate,
333         OBJ_xmms2_id,
334         OBJ_xmms2_duration,
335         OBJ_xmms2_elapsed,
336         OBJ_xmms2_size,
337         OBJ_xmms2_percent,
338         OBJ_xmms2_status,
339 #ifdef X11
340         OBJ_xmms2_bar,
341 #endif /* X11 */
342         OBJ_xmms2_smart,
343         OBJ_xmms2_playlist,
344         OBJ_xmms2_timesplayed,
345         OBJ_if_xmms2_connected,
346 #endif /* XMMS2 */
347 #ifdef AUDACIOUS
348         OBJ_audacious_status,
349         OBJ_audacious_title,
350         OBJ_audacious_length,
351         OBJ_audacious_length_seconds,
352         OBJ_audacious_position,
353         OBJ_audacious_position_seconds,
354         OBJ_audacious_bitrate,
355         OBJ_audacious_frequency,
356         OBJ_audacious_channels,
357         OBJ_audacious_filename,
358         OBJ_audacious_playlist_length,
359         OBJ_audacious_playlist_position,
360         OBJ_audacious_main_volume,
361 #ifdef X11
362         OBJ_audacious_bar,
363 #endif /* X11 */
364 #endif /* AUDACIOUS */
365 #ifdef BMPX
366         OBJ_bmpx_title,
367         OBJ_bmpx_artist,
368         OBJ_bmpx_album,
369         OBJ_bmpx_track,
370         OBJ_bmpx_uri,
371         OBJ_bmpx_bitrate,
372 #endif /* BMPX */
373 #ifdef EVE
374         OBJ_eve,
375 #endif /* EVE */
376 #ifdef HAVE_CURL
377         OBJ_curl,
378 #endif /* HAVE_CURL */
379 #ifdef RSS
380         OBJ_rss,
381 #endif /* RSS */
382 #ifdef WEATHER
383         OBJ_weather,
384 #endif /* WEATHER */
385 #ifdef XOAP
386         OBJ_weather_forecast,
387 #endif /* XOAP */
388 #ifdef HAVE_LUA
389         OBJ_lua,
390         OBJ_lua_parse,
391         OBJ_lua_bar,
392 #ifdef X11
393         OBJ_lua_graph,
394         OBJ_lua_gauge,
395 #endif /* X11 */
396 #endif /* HAVE_LUA */
397 #ifdef TCP_PORT_MONITOR
398         OBJ_tcp_portmon,
399 #endif /* TCP_PORT_MONITOR */
400 #ifdef HAVE_ICONV
401         OBJ_iconv_start,
402         OBJ_iconv_stop,
403 #endif /* HAVE_ICONV */
404 #ifdef HDDTEMP
405         OBJ_hddtemp,
406 #endif /* HDDTEMP */
407         OBJ_include,
408         OBJ_blink,
409         OBJ_to_bytes,
410         OBJ_scroll,
411         OBJ_combine,
412         OBJ_entropy_avail,
413         OBJ_entropy_perc,
414         OBJ_entropy_poolsize,
415         OBJ_entropy_bar,
416 #ifdef APCUPSD
417         OBJ_apcupsd,
418         OBJ_apcupsd_name,
419         OBJ_apcupsd_model,
420         OBJ_apcupsd_upsmode,
421         OBJ_apcupsd_cable,
422         OBJ_apcupsd_status,
423         OBJ_apcupsd_linev,
424         OBJ_apcupsd_load,
425         OBJ_apcupsd_loadbar,
426 #ifdef X11
427         OBJ_apcupsd_loadgraph,
428         OBJ_apcupsd_loadgauge,
429 #endif /* X11 */
430         OBJ_apcupsd_charge,
431         OBJ_apcupsd_timeleft,
432         OBJ_apcupsd_temp,
433         OBJ_apcupsd_lastxfer,
434 #endif /* APCUPSD */
435 };
436
437 struct text_object {
438         struct text_object *next, *prev;        /* doubly linked list of text objects */
439         struct text_object *sub;                /* for objects parsing text into objects */
440         union {
441                 void *opaque;           /* new style generic per object data */
442                 char *s;                /* some string */
443                 int i;                  /* some integer */
444                 long l;                 /* some other integer */
445                 unsigned int sensor;
446                 struct net_stat *net;
447                 struct diskio_stat *diskio;
448                 unsigned char loadavg[3];
449                 unsigned int cpu_index;
450                 struct mail_s *mail;
451
452                 struct {
453                         char *args;
454                         char *output;
455                 } mboxscan;
456
457 #ifdef X11
458                 struct {
459                         int l;
460                         int w, h;
461                 } mixerbar;             /* 3 */
462 #endif
463
464                 struct {
465                         int fd;
466                         int arg;
467                         char devtype[256];
468                         char type[64];
469                         float factor, offset;
470                 } sysfs;
471
472                 struct {
473                         struct text_object *next;
474                         char *s;
475                         int i;
476                         char *str;
477                 } ifblock;
478
479                 struct {
480                         int num;
481                         int type;
482                         int was_parsed;
483                         char *s;
484                 } top;
485
486                 struct {
487                         double last_update;
488                         float interval;
489                         char *cmd;
490                         char *buffer;
491                         double data;
492                         timed_thread *p_timed_thread;
493                 } execi;                /* 5 */
494
495                 struct {
496                         int a, b;
497                 } pair;                 /* 2 */
498 #ifdef TCP_PORT_MONITOR
499                 struct tcp_port_monitor_data tcp_port_monitor;
500 #endif
501 #ifdef EVE
502                 struct {
503                         char *apikey;
504                         char *charid;
505                         char *userid;
506                 } eve;
507 #endif
508 #ifdef HAVE_CURL
509                 struct {
510                         char *uri;
511                         float interval;
512                 } curl;
513 #endif
514 #ifdef RSS
515                 struct {
516                         char *uri;
517                         char *action;
518                         int act_par;
519                         float interval;
520                         unsigned int nrspaces;
521                 } rss;
522 #endif
523 #ifdef WEATHER
524                 struct {
525                         char *uri;
526                         char *data_type;
527                         int interval;
528                 } weather;
529 #endif
530 #ifdef XOAP
531                 struct {
532                         char *uri;
533                         unsigned int day;
534                         char *data_type;
535                         int interval;
536                 } weather_forecast;
537 #endif
538                 struct {
539                         char *text;
540                         unsigned int show;
541                         unsigned int step;
542                         unsigned int start;
543                         long resetcolor;
544                 } scroll;
545
546                 struct {
547                         char *left;
548                         char *seperation;
549                         char *right;
550                 } combine;
551
552                 struct {
553                         char *host;
554                         unsigned int port;
555                 } read_tcp;
556
557                 struct local_mail_s local_mail;
558         } data;
559         int type;
560         int a, b;
561         long line;
562         unsigned int c, d, e;
563         float f;
564         char char_a, char_b;
565 };
566
567 /* text object list helpers */
568 int append_object(struct text_object *root, struct text_object *obj);
569
570 /* ifblock helpers
571  *
572  * Opaque is a pointer to the address of the ifblock stack's top object.
573  * Calling clients should pass the address of a defined void pointer which
574  * was initialised to NULL (empty stack).
575  * */
576 int obj_be_ifblock_if(void **opaque, struct text_object *);
577 int obj_be_ifblock_else(void **opaque, struct text_object *);
578 int obj_be_ifblock_endif(void **opaque, struct text_object *);
579 int ifblock_stack_empty(void **opaque);
580
581 #endif /* _TEXT_OBJECT_H */